Hi,
thanks for your question.
Yes, excluding certain columns from the search is possible with extra code for the DataTables JS library. Please add this to the “Custom Commands” textfield on the “Edit” screen of the table:
"aoColumnDefs": [ { "bSearchable": false, "aTargets": [ 0 ] } ]
The 0 indicates that the first column should be excluded (counting starts with 0 in the code).
Regards,
Tobias
One more question. I’m also using the command you referenced in another discussion to hide a column, but still make it searchable:
“aoColumnDefs”: [ { “bVisible”: false, “aTargets”: [ 4] } ]
How would I utilize both of these at the same time? I can get them both to work when used alone, but when I input both into the custom commands field, The search bar goes away and neither of the commands work.
Thanks!
Hi,
you’ll just have to merge these two commands to one:
"aoColumnDefs": [ { "bSearchable": false, "aTargets": [ 0 ] }, { "bVisible": false, "aTargets": [ 4 ] } ]
Regards,
Tobias
Hi,
sure, no problem, you are very welcome! 🙂 That’s good to hear!
Best wishes,
Tobias
P.S.: In case you haven’t, please rate TablePress here in the plugin directory. Thanks!
Hi Tobias,
Thanks for the TablePress plugin. While checking above codes for search activation for hidden column, I found that search text box and number of items list disappear after adding above in JS call.
Is any extra code required apart from above?
Will appreciate your support.
thanks,
Raj,
Thanks I managed to work out on the code.
Hi,
very nice! Most likely, there was just a typo, and that then broke the JS code.
Best wishes,
Tobias
P.S.: In case you haven’t, please rate TablePress here in the plugin directory. Thanks!