Hi,
thanks for your question.
You are correct. When columns are hidden via the “Edit” screen checkboxes in WP-Table Reloaded, they can not be searched on the frontend.
This is however possible with some extra commands for the DataTables library, just as on that page that you found. Good thing: There’s no need to load DataTables to your page manually for this!
You can just use the “Custom Commands” textfield in the “DataTables JavaScript features” section below the table input fields on the “Edit” screen of your table.
There, you’ll want to enter something like
"aoColumnDefs": [ { "bVisible": false, "aTargets": [ 0, 3 ] } ]
This would for example hide columns 1 and 4 (counting starts at 0), but they should still be searchable.
Regards,
Tobias
thanks Tobias.
indeed the custom command does work, but i need to load DataTables manually because i’d like to retain the dropdown column filter at the footer of the table. is there a way to use both functions at the same time?
Hi,
ah, ok, I see. In that case, you will need to add this “Custom Command” directly to the lines
var oTable = $('#wp-table-reloaded-id-16-no-1').dataTable({
"oLanguage": {
"sSearch": "Search all columns:"
}
});
in your manual code, like
var oTable = $('#wp-table-reloaded-id-16-no-1').dataTable({
"aoColumnDefs": [ { "bVisible": false, "aTargets": [ 0, 3 ] } ],
"oLanguage": {
"sSearch": "Search all columns:"
}
});
Regards,
Tobias
works a charm! thanks Tobias (once again!)
Hi,
great 🙂 Thanks for the confirmation!
And you are very welcome!
Best wishes,
Tobias
Ah…
Yes I can hide columns I want and still search them, but then the footer column filters are incorrect. For example, if I hide columns 0 and 1, they are hidden and columns 2 and 3 appear first. But the column footer filters shows dropdown info for 0 and 1, and not the info for 2 and 3.
Hope that makes sense!
Hi,
yeah, that makes sense, I think I understand what is happening here.
Unfortunately, I have no idea how to change or fix this, and I think I’m the wrong person to ask. This is better suited for the real DataTables experts, which you can find in the forums at http://www.datatables.net
Remember, I’m not the developer of DataTables, I just added it to WP-Table Reloaded 🙂
Best wishes,
Tobias
Thanks Tobias – that makes sense!
Do you have an email address I can write to?
Hi,
you can find my email address in the main plugin file of WP-Table Reloaded, wp-table-reloaded.php (if you meant my email address).
For DataTables, I don’t know an address, you should write in the forums there probably.
Regards,
Tobias