Hide table until search selection

Hide table until search selection

HalisHalis Posts: 1Questions: 1Answers: 0

Hello, I'm running DataTables column filtering widget on the Wordpress "Tablepress" plugin and what I'd like to do is that when a user enters the page that has the table, instead of all of the rows appearing, the table rows shouldn't be visible but the column dropdowns should be and when the user makes a selection only the rows that match the selection should appear.

I'm a little bit new to coding so if you guys could thoroughly guide me through this I'd appreciate it. Thanks.

Answers

  • jLinuxjLinux Posts: 981Questions: 73Answers: 75
    edited November 2015

    So, you want something like this, but the table to not be visible until search results are found, correct?

    I guess the best thing to do would be to use the API, on every draw, check if any() rows are found (via something like table.rows( {page:'current'} ).any(), if false, just use $().css to hide the table, otherwise, show the table via the same css setting.

    If you're looking for someone to do it for you, then you would need to look to hire a developer, apologies.

  • jLinuxjLinux Posts: 981Questions: 73Answers: 75
    edited November 2015

    I dont usually do free dev work, but this was very simple to do a proof of concept, here

    If you want to do the column searching instead, that should still work fine really, just combine the two

    If you want to hide the other features (length selection, pagination, etc), then you would have to apply those CSS calls to .dataTables_wrapper, but that would also hide the search input, so be sure to have an external search (Which is what this is, so it would work fine)

This discussion has been closed.