Sorry, we don't support your browser.  Install a modern browser

Dynamic Table Placeholders#373

Make it possible to get parameters passed to a wpDataTable and update a Placeholder value with the parameter passed:
URL Example:
www.abc.com/?param1=abc

wpDataTable placehholder:
%var1% = param1

5 months ago

Hello Rudi,

Thank you for your suggestion. Could you provide a more precise explanation so that we can have clearer information for our future development? Currently, we have an option to use URL parameters for filtering, as shown in this link (Advanced filtering). Maybe this could help you for now.

https://wpdatatables.com/help/faq/

4 months ago

Hi Stefan,

I’m familiar with URL filtering. This essentially return the whole table with a ‘filter’, but if the filter is removed the whole table is accessible.

What I’m suggesting is to allow PLACEHOLDERS to reference parameter names passed in URL’s. This will make it possible to make dynamic tables which are prefiltered record sets based on a hard Placeholder filter.

Example:
Currently:

  • There are 9 Placeholder options which can be “harcoded”, limiting Placeholders to a possible 9 different hardcoded values. In the wpdt youtube video Countries are used as an example - There are more than 9 countries in the world…

My suggestion:

  • Make Placeholders dynamic by specifying a Parameter name and then passing a value into the placeholder Parameter.

Placeholder %VAR1% = “param1”

  • The value for “param 1” is passed in the URL and could be any value.
4 months ago
1
Changed the status to
In Progress
2 months ago
2

As a novice user I’m just commenting that this is an interesting suggestion and I can also see some use scenarios for this.

I’m wondering though what should happen if the parameter (and variable) is omitted from the URL. There is a way to set a default fallback value or the whole table is accessible again..? Although I don’t know if this is a problem or not, depends on the scenario of the original suggestion.

2 months ago
R

I have a table with over 3 million rows representing residuals from movies or TV of which only handful need to be accessed for any particular product (movie) in a tab for that product. I would prefer not to load all 3 million records with “pre-filtering” and I have to hide the column with css that the filter is based on. Currently, I plan to use the filter wpdatatables_filter_mysql_query to perform the filtering, but it would be better to have the feature suggested in this thread.

a month ago
R

The solution with wpdatabases_filter_mysql_query does not work.
However another solution is to create your own short code that builds the wpDataTables shortcode dynamically with the WordPress function do_shortcode:
add_shortcode( ‘queryparamdatatable’, ‘queryparamdatatable’);
function queryparamdatatable( $atts ) $default = array(‘id’ => ‘’, ‘queryparam’ => ‘’);
$a = shortcode_atts( $default, $atts );
$id = $a[‘id’];
$param = $a[‘queryparam’];
$var1 = $_GET[$param];
$string = ‘[wpdatatable id=’.$id.’ var1=’.$var1.’]’;
error_log($string);
echo do_shortcode(‘[wpdatatable id=’.$id.’ var1=’.$var1.’]’);
}
Then use %VAR1% in SQL statement for the wpDataTable.

a month ago
1