StateSave and column visibility
StateSave and column visibility
Hi,
i have a datatable where i define on TH a class "not-visible" if the column should be hidden.
This visibility class is set based on some conditions.
I am also using statesave, so users keep the search etc.
The problem is, when the state is saved and "not-visible" is changed, these columns behave strangely.
What would be a proper way to handle this scenario?
This discussion has been closed.
Answers
When state saving is enabled, the state that is loaded will be the one that "wins". State saving will override the initialisation settings - that's the whole point of state saving .
So to allow your class to work, you'd need to clear the saved state.
Allan
OK, i understand that, it is logical
But, I bet i am not the only one with such a case. And for this kind of situations, is there really no way like saying: ok, save everything, but ignore columns (with some kind of identifier, in my case css class.).
My case is that i have users who have their roles. And based on permissions set to a role, a column for mass edit (check boxes) is hidden or visible.
This is pretty much the whole story
And it is a big decision/tradeoff between usability of datatable save state and being able to set some security based elements inside the table.
Thx for the answer
Yes, you can have it ignore columns. The
stateSaveParams
callback can be used for this. You can have it delete the columns parameter and everything will be saved except the column information.Allan
Can you post an example?
For example (with StateSave: true and target column = 1 with visible: false and class="col_to_hide") using:
"stateSaveParams": function (settings, data) {
//
}
If you want to not state save column visibility you could remove the
visible
parameter from the columns array of objects in the state object:Allan