Default filter settings, similar to aaSorting.
Default filter settings, similar to aaSorting.
Hi, Allan.
Seems it is impossible to set default filter values per column, juts like we can set default sorting. We found it useful in our use case - show items with status "Active" by default, and i'm sure there are many other similar use cases. It would be great, if we could setup datatables to get already filtered data from server, similar as sorted and paged.
What you think?
Seems it is impossible to set default filter values per column, juts like we can set default sorting. We found it useful in our use case - show items with status "Active" by default, and i'm sure there are many other similar use cases. It would be great, if we could setup datatables to get already filtered data from server, similar as sorted and paged.
What you think?
This discussion has been closed.
Replies
If you want to make the filter removable or changeable and prefer to hide some rows "by default", change filter input value and trigger "keyup" event after the table is loaded.
Yes, and this is our user case. We are not using datatables input controls, we have our own filter controls, like dropdown for entities with specified status and checkbox for show/hide draft entities. In the initial state, grid should show only active entities with no drafts, so we already have 2 filters - and we need to pass these filters to datatables _before_ it send request to ajax source. Ofcourse, user restricted with our filter controls - thats our use case.
What u think?
2. In other case, if you can not reduce rows count on database or service layer, you can excute oTable.fnFilter() function to filter the rows after they are added to the table.
2. Also not sure i understood you. We need to filter rows _before_ they added to datatables, we need to filter entire dataset on the server, then let datatables show all received data.
We can't use datatables filter input controls. So we have our own control - a dropdown. We call function fnFilter(filterValue, colIndex) each time user selects new value, datatables sends request to server with filter value for certain column in the ajax request and gets filtered data - all works as expected, everything is fine. But our problem is that dropdown control has default selected value, and we need to pass it somehow to datatables, before it issues very first ajax request for data retrieving, ideally during configuration.
Guys, maybe this suggestion is not valid, or can't be implemented, or i missed some key concept of datatables?
I see your point with initial variables, and I think it would be correct to expose them at initialisation time (it might indeed be correct to expose all of the settings object - I'll have a look at that). I think having an initial filtering state ("Enabled" is a good example) is a perfectly valid use case.
One way that this could actually be done at the moment (since you are using server-side processing) is to add a custom variable to the data sent to the server which will do the filtering for you. In this way, DataTables doesn't need to know anything about it.
Regards,
Allan
Can't wait next beta :)