Filtering on hidden column defeated by new sort-- how to reenable?
Filtering on hidden column defeated by new sort-- how to reenable?
Hi,
I have filtering on hidden columns, driven by a dropdown menu, implemented and working very well. However, when you choose to resort the (filtered) entries, the filtering is dropped and all entries reappear.
It looks like the callbacks don't really fit the bill for addressing this, because if I use fnDraw callback, there'll be a second where the entire, unfiltered table is still visible before I filter again.
Any suggestions welcomed.
Thanks!
I have filtering on hidden columns, driven by a dropdown menu, implemented and working very well. However, when you choose to resort the (filtered) entries, the filtering is dropped and all entries reappear.
It looks like the callbacks don't really fit the bill for addressing this, because if I use fnDraw callback, there'll be a second where the entire, unfiltered table is still visible before I filter again.
Any suggestions welcomed.
Thanks!
This discussion has been closed.
Replies
I'm not seeing this problem with my multi-column filtering example: http://datatables.net/examples/example_multi_filter.html
What should happen is that DataTables will cache the filter for each individual column, and for the global filter, and then reapply that information once a sort has occurred. I sort of vaguely remember a bug about this a long while back, but the current 1.4 and 1.5 (beta) releases don't appear to be showing this problem. Could you post any more information (ideally with a link showing the problem)?
Thanks,
Allan
I figured out the issue. I used bFilter=false because I don't want the "search" box to appear (filtering is done through the API via a dropdown menu). If bFilter''s false though, dataTables doesn't resort after changing the sort order. Is there a way to get the best of both worlds?
Thanks.
So you want filtering support (i.e. fnFilter()) but not the text box? Yup - no problem there. What you need to do is use the sDom option ( http://datatables.net/usage#sDom ) and drop the 'f' option from the string. This will cause DataTables to not insert the filtering input into the DOM, but it will have all it's internals required for filtering switched on :-)
Allan
[code]
var commentTable = $('#commentsBlock #commentsTable').dataTable( {
"bFilter" : true,
"bInfo" : false,
"bLengthChange" : false,
"sDom" : 'itp',
"bPaginate" : false,
"aoColumns" : [ { "bVisible" : false }, // potentialAnswerId
{ "bVisible" : false }, // group name
{ "bSortable" : true }, // date
{ "bSortable" : true }, // comment
{ "bSortable" : true } // useful?
]
} );
[/code]
In the above, filtering is enabled, but I only want dataTables to render the info text, the table itself, and the paginator, so there's no 'f' in the sDom string I pass in for that param.
Thanks, Allan, you rock.
That's great, thanks for posting your code. One thing to note is that you don't actually need to have "bFilter": true, since this is the default value. But then given that the filtering isn't in the sDom, there is no harm in being verbose :-)
Regards,
Allan
I had a very similar problem and that thread fixed it,
Thanks,
Gabor