ColReorder with Keytables (cell.render) does not give the correct value after reordering a column

ColReorder with Keytables (cell.render) does not give the correct value after reordering a column

patackpatack Posts: 6Questions: 1Answers: 0

Hi Everyone,

I have the following problem: For cells of a specific column, i am rendering "Press Enter for details" for type === 'display'. If the user presses enter on a specific cell of this column, i am presenting the data rendered from type === 'export' with cell.render('export'). So this works well as long as the user is not reordering this specific column via Colreorder. After reordering the specific column --> cell.render('export') will just give back "Press Enter for details" - instead of showing the correct data behind cell.render('export'). Do you have solution for that?

Testcase: http://live.datatables.net/pinebici/2/edit

Here the specific column is "Position". When you press enter on a cell of this column you will see the correct value from cell.render('export'). nevertheless after reordering of this column and then pressing enter you will just see "Press Enter for details" within the console.

This question has accepted answers - jump to:

Answers

  • allanallan Posts: 63,542Questions: 1Answers: 10,476 Site admin
    Answer ✓

    Yup this is a cracker - took me a few minutes to spot what is going on and I wrote it! So totally non-obvious.

    What is happening is that when you have a DOM sourced table (this is important) when ColReorder does a reorder, rather than shuffling the data array for each row, it is actually just invalidating the row and that causes DataTables to read the data for the row back in.

    The upshot of that is that the cell's data is actually now Press Enter for details which is why you see that on the console.

    If you Ajax (or use data) sourced data - the invalidation does not read from the HTML, but rather from the data. In such a case it works as expected: http://live.datatables.net/pinebici/4/edit .

    This is the line in question. With rows().invalidate() we could get it to read the data array, but that wouldn't be right in this case.

    I need to have a bit of a think about how to handle this correctly.

    Is Ajax sourced data an option for you?

    Allan

  • patackpatack Posts: 6Questions: 1Answers: 0

    Thanks allan for your fast respond. Ajax is possible but a hell of job to go. Im loading XML from database BLOB and transform it with .xslt to HTML with different xslt-sheets. The HTML is then used by Datatables. Since the columns are highly dynamical +60 different configurations - i think data is also not really an option :/

    `

  • allanallan Posts: 63,542Questions: 1Answers: 10,476 Site admin

    Okay - thanks. I will see if there is something I can do about that next week :)

    Allan

  • patackpatack Posts: 6Questions: 1Answers: 0

    your the best!

  • allanallan Posts: 63,542Questions: 1Answers: 10,476 Site admin
    Answer ✓

    Hi,

    To follow up on this, I've just committed a fix for this issue. I've also committed a fix for ColReorder with KeyTable where the focus wasn't moving with the reordered columns.

    Those changes will need an update to both KeyTable and ColReorder on your system. I'll do a release of them soon, but until then, you can try out the fix using the nightly (which will rebuild in just a few minutes from the time of me writing this).

    Allan

  • allanallan Posts: 63,542Questions: 1Answers: 10,476 Site admin

    Hi,

    Following up on your PM on this topic regarding ColReorder with state saving in this configuration, I've just committed another change to address that issue.

    The nightly will rebuild and be up to date with the change in the next few minutes.

    Allan

  • patackpatack Posts: 6Questions: 1Answers: 0

    That did the trick! thank you very much!

Sign In or Register to comment.