Closed lvmajor closed 4 years ago
This might be implemented in another way if you prefer (so it better aligns with the other extensions). I didn't have time to check how it was done in other extensions, but I guess it is similar, using the defaults options which are extended with instance options at init. time
Just a note, this might need some edits as it was created prior to some other changes that were merged recently. If interested, please just ping me and I'll provide another PR with an updated version of this edit to support setting the stateSave
status separately for this extension only (if desired, takes the global one by default)
Hi,
Thanks for the PR! The way we've approached this with DataTables core and the extensions is that you would use stateSaveParams
to delete the parameters that you don't want saved. E.g. don't want ordering saved: delete data.order
and the software will handle that partial state.
As such, I'm going to close this - my concern here is that it would be a new paradigm for the extensions and features and for consistency we'd need to implement this for everything else. Perhaps in future we should do something like stateSave: { ordering: false }
, but for the moment we'll stick with the stateSaveParams
option.
Allan
All right, I understand your concerns. Is there an example on disabling state saving just for Searchpanes though? Last I checked there was none and this seems pretty important to me as I don't really understand how state saving can work fine with searchpanes and ajax reloaded table (in which case some selected filters in panes could be totally absent from the new data set being loaded)
There isn't an example of that - although it would be an extension of what I suggested above, just deleting all of the other parameters as well that you don't want.
Regarding the applied filters, I believe it will reselect the items that it can (based on id), but I'm going to hand over to @SandyDatatables for that...
Yeah I'm eager to hear from Sandy about this as filtering based on id cannot possibly work in a scenario where the values after ajax reload in the pane might be totally different and in which case filtering based on the previous selection's id would be totally useless (and might even cause confusion/problems) in my opinion.
As for the stateSaveParams... I will have to try and understand how I could apply it without affecting the main tables in which I do want state save to happen. As at the moment, the panes are tables themselves which are internally generated by the extension, so would I have to pass specific stateSave
options to each of the panes by using a custom panes section in the options? (as mentioned here
Yes it will reselect any selections that were there previously. In the case that there was a selection whose data is no longer present, SearchPanes will add a row based upon the previously stored details form when it did exist. Take a look at these lines
The selections store the filter value of the cells in the rows, not the id of the rows ensuring that the correct rows are selected. Another way for you to simply clear the panes is by using the searchPanes.clearSelections()
method. You can find the documentation for this method [here](https://datatables.net/reference/api/searchPanes.clearSelections()).
@SandyDatatables could you explain a bit (you don't have to, it's just out of curiosity) why you are adding the values to the new pane in the scenario where the new data does not contain this value anymore?
Oops - sorry for the misinformation. Storing by value as Sandy says makes much more sense here and I remember us discussing that in the past now.
That said, I'm also not sure about the adding of values which aren't in the data set. We'll have a chat about that and report back with what we come up with.
Reopening until fully resolved.
Hi @os1r1s110 ,
We've had a talk about this and have decided that if a previously selected value is present then it should be reselected, and if it is not present then it won't be added. I've made some changes to implement this behaviour, take a look at this commit. You can also give the behaviour a try in this example.
I should also note that the code that I referenced previously doesn't actually relate to the ajax reload. It's actually used in cascadePanes, I got the behaviour mixed up in my head!
Thanks, Sandy
Thanks for the update, really appreciated.
No worries. Thank you for putting the effort in to help us spot bugs like this, it's really useful for us. I'm going to mark this closed now.
Thanks, Sandy
@SandyDatatables and @AllanJard sorry for reopening the discussion here but I just updated everything to the latest version and I would have a question for you guys....
How can I disable StateSave only for Searchpanes via the SateSaveParams? (as Allan suggested in a previous comment)... It seems like the parameter data.searchPanes does not exist yet when the callback is made (at the main table level) and is only added later on by the Searchpanes extension, but I don't seem to have a way to prevent it from state saving....
Is there a built-in way to do it or is state saving and all or nothing solution for Searchpanes? (By this I mean, if StateSave is active on the main table, then we have no choice but to have state save on Searchpanes too... ???)
Contrary to what Allan said in previous comment, it doesn't seem possible to disable it by removing the data.searchPanes
to prevent it from being saved)
Thanks for the PR! The way we've approached this with DataTables core and the extensions is that you would use
stateSaveParams
to delete the parameters that you don't want saved. E.g. don't want ordering saved:delete data.order
and the software will handle that partial state.
Thanks in advance and have a great day!
Adding a new default option (set to true to respect current behavior) to let the users define a specific
stateSave
setting for thesearchPanes
extension instead of only relying on the globalstateSave
option, a little bit like what is done with certain third-party datatables plugins (checkboxes)