See:
https://tablepress.org/demo/ -> 2nd table.
If “filter/search” is enabled the search input is missing here, too.
Hi,
this is the expected behavior. The DataTables JS library simply doesn’t support tables with combined cells (via colspan or rowspan).
Regards,
Tobias
Hello Tobias,
thank you for the fast response. That doesn’t matter (25 table rows). The table itself works which is more important.
Have a nice week 🙂
Sascha
Hello Tobias,
there still is a bug:
Currently there are 492 entries. When you select e.g. the first entry you wil get 284 hits. After clicking the “Next” link the compleate is gone and the 492 entries are back.
See:
http://www.regionalmuseum-alsfeld.de/dokumente/lexika/bauwerke/
This is the responsible code:
let jTable = $('#tablepress-' + tableID);
let filterValue = 'blah';
if (searchColumns.length > 0){// search single columns
//jInput.keyup();
jTable
.DataTable()
.search( '' )// remove global columns filter (empties search input field, too)
.columns( searchColumns )// search within single column only
.search( filterValue, searchRegex, searchSmart )
.draw()
.search( '', searchRegex, searchSmart )// remove single columns filter (but do NOT redraw table)
;
}
I know that this is my problem with DataTables but maybe YOU can help me :).
Cheers
Sascha
Hi Sascha,
I can only assume that the pagination resets the filtering, but unfortunately, my knowledge about these aspectes of DataTables are too limited. Sorry 🙁
Regards,
Tobias
I believe that the last .search() call causes the issue.
That’s ok. I will look for a solution and post it here.
Hi,
yes, searching after the draw() might not have an effect.
I hope that you can find a solution!
Regards,
Tobias
Hello Tobias,
GOT IT! The “Next” button works now.
Solution:
You must store the current filter info values of searchColumns, searchRegex and searchSmart. I simply added a dynamically created property to FILTER_INFO[<table-id>].
Now the code can be read straight forward and should do the job (please please).
// empty last filter
let dataTable = jTable
.DataTable()
.columns( info.lastSearch.searchColumns )
.search( '', info.lastSearch.searchRegex, info.lastSearch.searchSmart )
.draw()
;
// search within selected column only
if (searchColumns.length > 0){
dataTable = dataTable.columns( searchColumns );
}
// perform search (at this point with or without searchColumn indices)
dataTable
.search( filterValue, searchRegex, searchSmart )
.draw()
;
// store current filter data
info.lastSearch = {
searchColumns: searchColumns,
searchRegex: searchRegex,
searchSmart: searchSmart,
};
// clear search input
jInput.val('').keyup();
Cheers
Sascha
Hi,
nice find! Thanks again for sharing it!
Best wishes,
Tobias
Hello Tobias,
The DataTables JS library simply doesn’t support tables with combined cells (via colspan or rowspan).
Found this:
https://wordpress.org/support/topic/datetable-functions-not-visible-if-using-colspan/#post-9610057
The search input field is shown here though colspan is set. I believe it works because colspan is within thead and not tbody.
Regards
Sascha
Hi,
yeah, using colspan in table headers is possible in DataTables, but only if there’s still a single header cell for each column. This means that the header would need to consist of two rows, which however TablePress does not support at this time.
The second link looks interesting, but it’s rather hacky. While it seems to work, the HTML code would no longer be valid, from what I can see… So, I’m not sure if I should add support for this… Maybe in the form of an Extension…
Regards,
Tobias