I have two differet WPdatatables on the same web page. I want to use URL links which pre-filter the second table, but not the first. When I use such a link, the firs table is tries to filter and say "No matching records found". The second table filters correctly.
Unfortunately, this will not work for multiple tables on the front-end as the filter will be applied to all filters with the same ID (in your case filter [1]).
You can, however, assign the value %VAR1% as a predefined filtering option for the "Sensor Name" column and then pre-filter the table through the shortcode.
So, [wpdatatable id=12] will return the non-filtered table, but [wpdatatable id=12 var1=mini] will add "mini" as a filter to this column. Instead of using the URL for the filter, you'd be using the placeholder.
Thanks for the reply Aleksandar. I'm not sure if this will solve my problem. I will have multiple links to the product table (from different product pages) and each link should send its own filter instructions.
For example, the link from the Mini page will filter the table for Mini, the link from the 60M page will filter the table for 60M and so on.
Your proposal will always filter by whatever variable is defined in the column properties and the shortcode text.
You can with a workaround. Please note that this does require some experience with writing SQL queries and using WP hooks.
You can create a table with a query like this:
SELECT user_id, user_name, user_address,
CONCAT('<a href="http:/yoursite.com/your_custom_page?user_id=',user_id,'">Details</a>') AS Details
FROM your_table_name
Then, on your_custom_page you will insert a shortcode of the table ID that you need, with a placeholder like this:
[wpdatatable id=1 var1=1]
The second table would be created from a query like this:
SELECT * FROM second_table WHERE user_id = %VAR1%
After that, you can use a hook for dynamic placeholders:
function updateVAR1($tableID){ global $wdtVar1;
//check is set GET parametar user_id
if(isset($_GET['user_id'])){
//get value from form fieald
$wdtVar1 = $_GET['user_id'];
}
}
add_action('wpdatatables_before_get_table_metadata', 'updateVAR1');
I hope this helps you achieve the results that you need.
I got this to work with my 2 tables. However it only filters records where my clientID is a number. Is this by design? The clientID field is a varchar type so even if it is showing as a number, it is actually characters. Example: record with clientID 'doug1234' does NOT show, but record with clientID of '3456' DOES show..
I have two differet WPdatatables on the same web page. I want to use URL links which pre-filter the second table, but not the first. When I use such a link, the firs table is tries to filter and say "No matching records found". The second table filters correctly.
for example: https://www.terabee.com/table/reseller-product-matrix/?wdt_column_filter[1]=Mini
Is there a way to identify in the URL which table is to be filtered?
thanks
Hello Philippe
Unfortunately, this will not work for multiple tables on the front-end as the filter will be applied to all filters with the same ID (in your case filter [1]).
You can, however, assign the value %VAR1% as a predefined filtering option for the "Sensor Name" column and then pre-filter the table through the shortcode.
So, [wpdatatable id=12] will return the non-filtered table, but [wpdatatable id=12 var1=mini] will add "mini" as a filter to this column. Instead of using the URL for the filter, you'd be using the placeholder.
Kind Regards,
Aleksandar Vuković
[email protected]
Rate my support
wpDataTables: FAQ | Facebook | Twitter | Instagram | Front-end and back-end demo | Docs
Amelia: FAQ | Facebook | Twitter | Instagram | Amelia 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
Thanks for the reply Aleksandar. I'm not sure if this will solve my problem. I will have multiple links to the product table (from different product pages) and each link should send its own filter instructions.
For example, the link from the Mini page will filter the table for Mini, the link from the 60M page will filter the table for 60M and so on.
Your proposal will always filter by whatever variable is defined in the column properties and the shortcode text.
Correct?
That is correct, Philippe, but...
You can with a workaround. Please note that this does require some experience with writing SQL queries and using WP hooks.
You can create a table with a query like this:
Then, on your_custom_page you will insert a shortcode of the table ID that you need, with a placeholder like this:
[wpdatatable id=1 var1=1]
The second table would be created from a query like this:
After that, you can use a hook for dynamic placeholders:
I hope this helps you achieve the results that you need.
Kind Regards,
Aleksandar Vuković
[email protected]
Rate my support
wpDataTables: FAQ | Facebook | Twitter | Instagram | Front-end and back-end demo | Docs
Amelia: FAQ | Facebook | Twitter | Instagram | Amelia 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
I got this to work with my 2 tables. However it only filters records where my clientID is a number. Is this by design? The clientID field is a varchar type so even if it is showing as a number, it is actually characters.
Example: record with clientID 'doug1234' does NOT show, but record with clientID of '3456' DOES show..
Hey John
I just responded to your open ticket: https://tmsplugins.ticksy.com/ticket/2878207/
Please take a look at it, and let me know on that ticket if you have any further questions.
Kind Regards,
Aleksandar Vuković
[email protected]
Rate my support
wpDataTables: FAQ | Facebook | Twitter | Instagram | Front-end and back-end demo | Docs
Amelia: FAQ | Facebook | Twitter | Instagram | Amelia 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