Okay
  Public Ticket #3359400
Filtering Table on Front-End
Closed

Comments

  • Mike Franklin started the conversation

    I want to create a single source of truth type of table. This table will have "category" as one of the columns. I want to display then only specific rows that match on that column. The user can do that with filters. But I want to only show/load the matching rows on the post specific to that category.

    For example, the master table has legal, sales, and customer service records. On the Customer Service page, I want to only display the records with the "customer service" category. 

    How do I accomplish this?

    Thanks.

  •  1,708
    Miloš replied

    Hi Mike.

    Firstly, I would like to sincerely apologize for the delayed response as we have been experiencing an unusually high number of tickets. I am sorry that it has taken longer than usual to respond to your concern and your patience is highly appreciated.

    -

    If i understood, you have the "category" as one of the columns, and you wish to make a page only for the Customer Service category rows, to filter the table for that page.

    You can achieve this in multiple ways, i will show some examples and you can try them out to see what will be the best for your use-case.

    -

    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 VAR1 value in the table's shortcode.

    -

    For example if i have this Master Manual Table,

    and i want to make a dynamic SQL Table with VAR1 placeholder.  ( Then later i can input different VAR1 in the table shortcode on different pages).

    7428149389.png

    My example SQL Query for the table will be :

    SELECT * FROM wp_wpdatatable_44
    WHERE company = '%VAR1%'

    First, just to initially generate an SQL table with the VAR1 ,

    i will set the Cakewalk  company name in the VAR1 , in table's Placeholders tab :

    8172791691.png
    5335724844.png

    9566344767.png

    -

    Then, for example, if i want to make a different page for another Company,

     let's say "Adobe".  Then i pass that value in the VAR1 of the table shortcode :

    6925292908.png
    8863319507.png

    2. 

    Or, if you don't add the condition in an SQL query, 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'] ,

    4565461533.png
    6779925578.png

     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)

    -

    I also made a short video example - please check it out here.

    Let me know if that helps.smile.png

    Kind Regards, 

    Miloš Jovanović
    [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