Local storage changes not reflecting
Local storage changes not reflecting

when we load the data table and then change the local storage settings, the table is not redrawing or showing the changes. What method do we need to call to make that work?
This discussion has been closed.
Answers
Hi @cuthbe123 ,
The table only uses the
stateSave
configuration when it is initialised. If you change these values afterwards, you'll need to reinitialise the table.Hope that helps, if not, we're happy to take a look, but as per the forum rules, please link to a test case - a test case that replicates the issue will ensure you'll get a quick and accurate response. Information on how to create a test case (if you aren't able to link to the page you are working on) is available here.
Cheers,
Colin
Okay so basically if I change the state underlying object I need to call $id.DataTable() again.
Yep, you'll need to destroy it first, as the table can't be reinitialised. Either add
destroy
to the initialisation, or calldestroy()
beforehand.Thanks so the destroy works but it takes out all of the css and everything. Thank you again for the suggestion. What I want to do is reload the column ordering after the table is initialised. Is there not an api to do that?
Hi @cuthbe123 ,
The destroy will take it out, but if you use it as the
destroy
, then it recreates the DataTable again, so the styling will be the same as it was.I'm not sure what you mean by reloading the column ordering after the initialisation. If you mean have a specific starting order, you can use
order
, if it it's something else, could you elaborate please.Cheers,
Colin
Hi Colin,
Okay so using
"destroy": true
that creates the table and drop all styling and configuration. Basically what I want to do is hold the table state i.e column positions and width on my server. But my application loads the table on startup so it is already initialised.
Hi @cuthbe123 ,
stateSave
doesn't hold any styling properties, like column positions and widths, it only saves column ordering, paging, searches, etc. If you want to include those, you'll need to add them yourself instateSaveParams
andstateLoadParams
,Cheers,
Colin
Okay so you are saying I can call
so push the column layout events into an already initialised table? What is the method to get the column layout and sorting order?
No, I'm saying the opposite
The searches are included, the styling isn't. The problem you'll have is that the width,
columns.width
is an initialisation property and can't be changed post-initialisation, so you'll need to reinitialise the table with the new value.