SaveState and FixedColumns

SaveState and FixedColumns

Benjamin.Smith@OptimalAnswers.comBenjamin.Smith@OptimalAnswers.com Posts: 15Questions: 2Answers: 0

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

  • tangerinetangerine Posts: 3,342Questions: 35Answers: 394

    It's "stateSave", and your example isn't using it.

  • kthorngrenkthorngren Posts: 20,142Questions: 26Answers: 4,736
    edited November 2021

    Not sure what you have in initComplete as it is empty in the test case. Make sure you are using this.api() to get an instance of the API in initComplete. Using the variable assigned to the Datatables init code is not available in initComplete.

    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

  • kthorngrenkthorngren Posts: 20,142Questions: 26Answers: 4,736

    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 and stateLoadParams to fetch the saved value and update via the API.

    Kevin

  • Benjamin.Smith@OptimalAnswers.comBenjamin.Smith@OptimalAnswers.com Posts: 15Questions: 2Answers: 0

    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?

  • kthorngrenkthorngren Posts: 20,142Questions: 26Answers: 4,736

    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

  • colincolin Posts: 15,112Questions: 1Answers: 2,583

    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

  • kthorngrenkthorngren Posts: 20,142Questions: 26Answers: 4,736

    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

  • colincolin Posts: 15,112Questions: 1Answers: 2,583
    Answer ✓

    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 like initComplete 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

  • Benjamin.Smith@OptimalAnswers.comBenjamin.Smith@OptimalAnswers.com Posts: 15Questions: 2Answers: 0

    Thank you so very very much!

  • sandysandy Posts: 913Questions: 0Answers: 236
    Answer ✓

    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

Sign In or Register to comment.