colReorder with stateSave not rendering properly when a column is added

colReorder with stateSave not rendering properly when a column is added

dudedudemdudedudem Posts: 2Questions: 0Answers: 0
edited July 2013 in General
Basics:
I am using colReorder and loading a saved string for column sort order

user sees their data with columns in order as they left it last
---example: "ColReorder":[4,1,0,3,2]

admin can change which columns the user can see
---example: adds one column to the user display

user loads table after admin adds a column and array does not match
---example: saved data = "ColReorder":[4,1,0,3,2] vs. default override = "ColReorder":[0,1,2,3,4,5]

** end result is user prefs are overwritten with the new default sort order **

Question:
can the original order be maintained with the new column simply being appended to the end of the original string?
---example: saved data = "ColReorder":[4,1,0,3,2] vs. sort order with new column appended = "ColReorder":[4,1,0,3,2,5]

To be clear up front, this is not throwing any sort of error but it would be nice not to reset the saved state each time a column is added or removed.

There is no publicly accessible URL to see an example so please let me know if I have not been clear enough.

Thank you very much in advance.

Replies

  • allanallan Posts: 63,516Questions: 1Answers: 10,472 Site admin
    edited July 2013
    Hi,

    Thanks for the clear explanation. It probably is possible to do what you are looking for - but the approach I've taken with all of DataTables (plug-ins included) is that if the columns change, then the column information is invalid, since there might be indexing errors (say you put column 5 in position 1 for example). It would make for errors that are hard to track and harder to cater for.

    So yes, it probably is possible to alter the source, but its not something I think I'll be putting into DataTables in the near future (unless there is some very cunning plan for how to deal with these issues - a hash of the columns would be ideal, but the information might be dynamic so that wouldn't work... :-( ).

    Regards,
    Allan
  • dudedudemdudedudem Posts: 2Questions: 0Answers: 0
    Thank you for your reply Allan.

    I understand completely and may try to configure a solution for my specific needs. If it proves fruitful and worthwhile I will post it here to share with others.

    Thank you again for your time. It is appreciated very much.
This discussion has been closed.