Can state restore support named column identification?

Can state restore support named column identification?

liamkearnliamkearn Posts: 4Questions: 1Answers: 0

Hi I'm using the state restore extension to persist and load states via ajax.

When persisting states I'm trying to avoid numerical indexes altogether as the ordering may change in the future or columns may come and go.

When loading states I'm getting an error from here: https://github.com/DataTables/DataTablesSrc/blob/0c820abf99a2a9f40d5f5df061fd9c4cbb607c10/js/core/core.sort.js#L44.

It seem it's trying to index aoColumns with an object returned from my ajax call that is loaded via state restore into aaSorting.

I'm not doing any data transformations here I'm just returning the structure that I was provided by state restore's ajax callback

This is what I'm provided in the callback and it's also what the ajax returns:

In short I guess what I'm asking is: Is it possible to use named columns with ajax callback state restore, is there an example I might have missed?

This question has an accepted answers - jump to answer

Answers

  • allanallan Posts: 62,858Questions: 1Answers: 10,344 Site admin
    Answer ✓

    At the moment no, sorry. This is something that needs to be improved across the board in fact. Our columns are primarily index based.

    Allan

  • liamkearnliamkearn Posts: 4Questions: 1Answers: 0

    Thanks Allan,

    I appreciate the work you're doing regardless. I'll update the post if I end up working around it or potentially even upstream :^)

  • liamkearnliamkearn Posts: 4Questions: 1Answers: 0

    Hi Allan,

    Apologies for the extra Q in a closed thread,

    Is there any sort of callback I use to customise the ordering functionality?

    eg. Intercept before the table is ordered and then map these textual keys to their current index if it exists?

  • liamkearnliamkearn Posts: 4Questions: 1Answers: 0

    Something like stateLoadParams but more specific to ordering?

  • kthorngrenkthorngren Posts: 20,992Questions: 26Answers: 4,887
    edited July 2023

    I'm not sure exactly what you are looking for. Here are a couple options to affect ordering:

    1. Use Orthogonal data
    2. Create a sorting plugin
    3. Use the columns.orderData

    If you still need help please build a simple test case with an example of your data so we can see what you are wanting to do to offer suggestions.
    https://datatables.net/manual/tech-notes/10#How-to-provide-a-test-case

    Kevin

Sign In or Register to comment.