SaveState and FixedColumns
SaveState and FixedColumns
Benjamin.Smith@OptimalAnswers.com
Posts: 15Questions: 2Answers: 0
in FixedColumns
Savestate isn't saving the number of saved columns. Attempting to call .left() in the initComplete event results in the error "Cannot read properties of undefined (reading 'fixedColumns')"
fiddle: https://jsfiddle.net/simaben/km1fdoew/34/
Is there a better approach?
This question has accepted answers - jump to:
Answers
It's "stateSave", and your example isn't using it.
Not sure what you have in
initComplete
as it is empty in the test case. Make sure you are usingthis.api()
to get an instance of the API ininitComplete
. Using the variable assigned to the Datatables init code is not available ininitComplete
.Sounds like you have a question about
stateSave
. That isn't enabled in your test case.Please update the test case to replicate the issues and provide the steps to see the problem.
Kevin
If the problem you are trying to solve is to keep the state of the number of fixeColumns you can use
stateSaveParams
to save the current number andstateLoadParams
to fetch the saved value and update via the API.Kevin
Thank you for your response, Kevin!
I've updated the fiddle to better illustrate the issue of .left() throwing an error in the initComplete section.
https://jsfiddle.net/simaben/km1fdoew/92/
I omitted the the stateSave portions for brevity as I was stating the new fixedColumns extension lacks the stateSave interoperability natively. Unless that's not true?
Interesting. This API was introduced in FixedColumns 4.0.0 and does work with 4.0.0:
http://live.datatables.net/dohayomi/1/edit
However if you load 4.0.1 it is not found. @allan or @colin will need to take a look at what happened.
Kevin
I might be being daft here, it happens often, but I'm not seeing that error in Kevin's example updated to 4.0.1: http://live.datatables.net/dohayomi/3/edit
Do I need to do something else to duplicate the problem?
Colin
Thats strange. I used the Add Library option to add FixedColumns and saw the error with 4.0.1. It was this morning so might not have had enough coffee. See the OP's last example.
Kevin
I moved it across to live, as I find it easier to work there, and yep, I'm seeing it. The problem isn't with 4.0.1, it's with
initComplete
- I've commented out that code, and the fixing works fine with just the buttons. So it looks likeinitComplete
is triggering before the FixedColumn extension does its stuff.I've raised it internally (DD-2389 for my reference) and we'll report back here when there's an update. As a workaround, you can add a timeout.
Cheers,
Colin
Thank you so very very much!
Hi @Benjamin.Smith@OptimalAnswers.com ,
That should be the issue fixed now as you can see at this example. This will be available in the next FixedColumns release which we hope will be in the next few weeks. Until then you can access the fix from the nightly builds.
Thanks,
Sandy