Okay
  Public Ticket #3700242
Filtering via a URL
Closed

Comments

  •  1
    Chris started the conversation

    I am trying to have a table filtered via a parameter passed to a page URL and do this by using the following SQL statement:-

    SELECT Errors.PaymentID, Errors.CheckId, Errors.Warning 
    FROM testing.Errors
    WHERE PaymentID = %VAR1%

    An example of the URL I'm using is

    https://veripaye.co.uk/errordetails/?passedID=18


    and I expect the passedID parameter (in this case 18) to replace the %VAR1% in the SQL statement, but instead I'm getting an empty table.

    The shortcode I'm using (in Elementor) is  

    [wpdatatable id=1 table_view=regular var1=passedID]


    I guess I'm doing something wrong and I need to parse the parameter from the URL somehow and call the shortcode with it.

    Any advice greatly appreciated.


    Chris

  •  2,572
    Aleksandar replied

    Hello Chris.

    I can't say much without taking a look at the table and the page, but looking at your shortcode, the %VAR1% placeholder would be replaced by "passedID" instead of an actual ID. If the URL is correct, and is dynamically passed to the URL, the value should be a number, so something like this:

    [wpdatatable id=1 table_view=regular var1=15]

    Even when I remove "?passedID=18" from the URL, the table is still empty (most likely because of a string being passed as VAR1. 

    Please provide me a temporary WP-admin (administrator) user for your site where this happens, so we could log in and take a look ‘from the inside’ as that’s the most efficient way to see and resolve the issue. 

    We do not interfere with any data or anything else except for the plugin (in case that’s a production version of the site), and of course, we do not provide login data to third parties. 

    You can write credentials here just check PRIVATE Reply so nobody can see them except us.


    Kind Regards, 

    Aleksandar Vuković
    [email protected]

    Rate my support

    wpDataTables: FAQ | Facebook | Twitter | InstagramFront-end and back-end demo | Docs

    Amelia: FAQ | Facebook | Twitter | InstagramAmelia demo sites | Docs | Discord Community

    You can try wpDataTables add-ons before purchasing on these sandbox sites:

    Powerful Filters | Gravity Forms Integration for wpDataTables | Formidable Forms Integration for wpDataTables | Master-Detail Tables

  •   Chris replied privately
  •   Miloš replied privately
  •   Chris replied privately
  •  1,846
    Miloš replied

    Hey Chris,

    I am glad to see you resolved this with a custom function, thank you for letting us know.

    I just wish to sincerely apologise for some wrong details I sent before, on this ticket, but also as I wrote on the other ticket here where we discussed the initial idea for combining two tables and making a relation between them, etc.


    When our developers added all these new options for the Master Details, such as switching from "POST" to "GET" Method for the Master Details Template Page/Post;  I was not aware that it is possible to actually have a "one-to-many" relation at all.

    When I did my testing for those features, I was unable to get it working like that, but recently I checked some examples our developers made, and realised, as they explained on this updated/refreshed Documentation page on Master-Details, it is possible to have 'one-to-many' relation between the Parent and Child Table if you choose "Send Child Table Data" and use the shortcode %wpdatatables_md_child_table% on your Template Page/Post.

    In other words, you can link one row in the parent table to multiple rows in the child table. This type of relationship enables each row in the parent table to have multiple corresponding rows in the child table, which is useful when you want to display all related data.

    If you wish to perhaps try, on this or another table/page, you can check out more details with a step-by-step guide on this Documentation Page. I will just point out the screenshots to make it easier to find it on the Page :

    1626385260.png

    You can also try out our example Table which is made from a parent table which contains "product details" so each row represents one Product, and we made a relation to a child Table "orders";

    2817047225.png

    The relation is made on the 'productID' column, so any row we click from the Parent Table is going to load a "Child table" which lists out all the orders of that specific product ( on my screenshot I will select product "laptop" and the 'orders' child table is going to load all the rows where that product has been ordered):

    7464616611.png
    6063909090.png
    3910247076.png

    Additionally, for this demonstration, we used a foreign key relation to store the "product ID" sa the 'store value' in the source SQL table while 'displaying' the 'product name' field as 'display value' to make it look nicer.

    Here is how the Parent table's Master details are configured :

    9861515122.png


    2. Additionally, what you asked originally, to pass the placeholder VAR1/variable value through the URL parameter itself, we also have this option.

    You can check out more details on this Documentation, but I will copy the important part here :

    Starting from wpDataTables version 6.4, you can pass values for our dynamic placeholders in the URL.

    If you set a variable placeholder as a predefined column filter value for any table type or use it in a Query for an SQL Query-based table, you can pass or change the VAR1 value by appending it to the page URL like this:

    ?wdt_var1=your_value

    To add multiple variables such as VAR1 and VAR2, if needed, you can separate them with an ampersand (&) like this:

    ?wdt_var1=your_value&wdt_var2=second_value

    Please note that any predefined filtering will not be possible to accomplish when using Cascade filtering logic from our Powerful filters Add-on.


    3. What we explained about passing variable values through the shortcode remains the same - I just wanted to make corrections on those two points, how we can make the 'one-to-many' relation via Master Details template page as Parent > Child tables;

    and how you can pass the VAR1 Placeholder via the URL of the Page for filtering, too.

    I hope that helps to at least clarify and correct what I wrote before, once again my apologies for the wrong informations earlier.


    Of course, if you try any of this and if you encounter any issue, don't hesitate to reach out to us.

    Thank you.

    Kind Regards, 

    Miloš Jovanović
    [email protected]

    Rate my support

    Try our FREE mapping plugin! MapSVG - easy Google maps, interactive SVG maps and floor plans, choropleth maps and much more - https://wordpress.org/plugins/mapsvg-lite-interactive-vector-maps/

    wpDataTables: FAQ | Facebook | Twitter | InstagramFront-end and back-end demo | Docs

    Amelia: FAQ | Facebook | Twitter | InstagramAmelia demo sites | Docs | Discord Community

    You can try wpDataTables add-ons before purchasing on these sandbox sites:

    Powerful Filters | Gravity Forms Integration for wpDataTables | Formidable Forms Integration for wpDataTables | Master-Detail Tables