Holiday Notice – Support Unavailable on April 18 and April 21

We just wanted to let you know that our support team will be offline on Friday, April 18th (Good Friday) and Monday, April 21st (Easter Monday) due to the holidays.
We'll be back on Tuesday, ready to assist you!

In the meantime, if you need any help, feel free to:

Amelia YouTube Channel

wpDataTables YouTube Channel

Thank you for your understanding, and we wish you a wonderful holiday weekend!

Okay
  Public Ticket #3600478
filtering with variable
Closed

Comments

  • Fritz Geiling started the conversation

    Thank you first for your help,
    I have already successfully created tables and I am looking for a solution on how I can pre-filter the existing tables.
    I have a local variable in my data set that I can query via php.
    For example, this is a specific number - let's say the number: 123
    This means that my variable called $variabe has the value 123
    In my table there is also a column with numbers from 1-1000.
    If the data set is now displayed in WordPress data set with the variable $variable and the corresponding value 123, I want my table to only display the corresponding row with 123 and not all 1000 rows.
    Is that somehow possible?
    Possibly with another plugin from DataTables.
    I hope that you can understand my concern with the somewhat complicated description.
    Thank you so much for your consideration and help - I would be very happy to hear your feedback.
    Kind regards
    Fritz

  •  1,894
    Miloš replied

    Hi Fritz,

    I am not sure if I fully understood how your variable will be called on the WP Page;

    but if you simply have a Column with these values in your Table, I will show you some examples how you can pre-filter Tables.


    There can be different ways to pre-filter tables in our plugin :

    If you wish to try Pre-filtering tables through URL,  please check out this page with examples.

    -

    You can also use placeholders for table generation.

    1. For example, if you have a MySQL query-based table, you can use this query:

    SELECT * FROM yourDatabaseTable
    WHERE columnName = '%VAR1%'

    %VAR1% can be defined in the Placeholders tab when you're creating a table, 

    or you can pass a different VAR1 value in the table's shortcode.

    -

    2. Or, if you don't add the condition in an SQL query ( or don't use an SQL Table),

    you can add %VAR1% in column settings -> Filtering, under "Predefined filtering value".

    Then, you can have different versions of the same table, with the VAR1 value passed in the shortcode,

    let's say if we had a "Regions" column and we wish to filter a different region per each page.

    9385158392.png

    If we want page 1 for example only filtered for "Region A" , you can set predefined filter to this column as %VAR1% (filter type has to be set as text) :

    4266306375.png

    Then for a page where we need only Region 1 filtered, use shortcode [wpdatatable id=1 var1='Region A'] ,

     page 2 for only "Region B", shortcode would be [wpdatatable id=1 var1='Region B'] and so on, 

    to apply the values defined in the shortcode to the filter.

    ( This filtering method can be used for any table type, besides Simple Tables)


    Let me know if that helps.

    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