Okay
  Public Ticket #2768125
Filters seem to be using the placeholder variables
Closed

Comments

  • Chris Rae started the conversation

    I'm noticing some odd behaviour when filtering one of my wpDataTables. You can see this yourself - if you go to the attached page and press the "Beach Name/Location" dropdown to enable filtering, there's a brief pause and then it offers you two beaches that aren't in this list at all.

    From my experimentation it would appear that these are the beach names returned from the example query in the wpDataTables editing UI, using the sample %VAR1% variable. And, indeed, changing %VAR1% does indeed change the list.

    I'm not sure if this is a bug or a feature, but is there any way to have this list read from the same query as the table itself did?

    Chris

  •  1,667
    Miloš replied

    Hi Chris,
    Thank you for your purchase.

    Yes, the filters will be used if you use VAR in the query, so the select box will return the data based on that VAR.

    To enable all the options in the select box, you can do that by going to column settings for that column, 

    go to data tab (attachment) and see if the option for Possible values for column  is set to be "Read from table  on page load"

    Also check if there are not any predefined values set for this column.

    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

  • Chris Rae replied

    Hi there - sorry, I should maybe have been a bit more clear. I am showing the table with:

    [wpdatatable id=1 var1='SC']

    The table works very well. However, the filter dropdown is using the "placeholder" variable values, and not the ones that were passed into the shortcode. I can verify this because if I change the placeholder value to "SC" then it shows the correct ones.

    I do already have the option to "read from table on page load" switched on.

    Thanks for your help,

    Chris

  •  2,496
    Aleksandar replied

    Hi again Chris

    What column is the variable assigned to?

    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 Rae replied privately
  •  2,496
    Aleksandar replied

    Hello Chris

    Thank you for the credentials.

    I created a new table #23 where I replaced VAR1 with an actual value, and when I add "SC" I get these results:

    4853486960.png

    So, 36 records total, and these are the same entries I see on the front-end page:

    6413506092.png

    So, it seems like the placeholder on the front-end is being replaced. It's not using "WA" anymore, but "SC" and "ALL", since that's the condition in the query:

    4407395381.png

    So, as you said - the page is displaying the correct values in the table (I spent some time on the table, so I'm just stating the obvious for me, I hope you don't mind).

    Now, the filter was set to pull only 10 values in the "Beach Name/Location" column's settings/Data tab:

    1965624213.png

    I changed that to "All", and now all values from the loaded table will be displayed in the dropdown filter on the front-end:

    2727062071.png

    As far as I can see, it is working fine now, but please take a look for yourself, and let me know.

    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 Rae replied

    Hi Aleksandar - thanks for looking into this! You're right - changing that option to "all" does seem to load the correct values. But unfortunately picking one of the values from that list doesn't seem to filter the table! It always gives 0 results, even when there should be some.

    Chris

  •  2,496
    Aleksandar replied

    Hi again Chris.

    Unfortunately, this is related to the query you're using. The PHP SQL parser we're using doesn't work correctly with JOIN, CONCAT, UNION functions, and sub-queries, so the generated tables that contain this will often not be filterable, sortable or searchable.

    To avoid this please prepare a MySQL view (a stored query), which will return the data that you need, call it e.g. “view1” and then build a wpDataTabled based on a simple query like “SELECT * FROM view1″.

    When you're working with the server-side processing feature:

    • Please do not use “LIMIT” in the SELECT statement. wpDataTables adds it automatically and it will be overridden.
    • Please do not use “ORDER BY” in the SELECT statement. wpDataTables has its own sorting engine so it makes no sense to use MySQL’s sorting since it will be overridden. Also, the server-side processing feature adds this part of the statement automatically when users trigger the sorting on the front-end, and having it in the initial statement may cause the table to crash.

    You can also disable "Server-side processing" for this table, and the filters should work properly, although you will not be able to edit the table in this case. Also, if the table filtered with the query displays more than 2.000 rows, it will automatically re-enable "Server-side processing".

    The query has to be inserted in the view up until the WHERE condition, where you're adding the placeholders. So, when you create the view, the query for a new table would be:

    SELECT * FROM view1
    WHERE (ms.meta_value = '%VAR1%' OR '%VAR1'% = 'all')

    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 Rae replied

    Hi Aleksandar - thank you very much for looking into it! I've turned off server side processing; I don't think I need it and now the table works perfectly!

    Many thanks for your help, and thanks for building a great product. We've used it for quite a few things!

  •  2,496
    Aleksandar replied

    You're welcome, Chris, I'm glad to hear it's working fine.

    If you have any further questions or issues, please feel free to open a new ticket, and we'll gladly help.

    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