Locking a column to prevent it from rearranging?

Locking a column to prevent it from rearranging?

intint Posts: 7Questions: 0Answers: 0
edited October 2009 in General
One of the columns in my application just displays a count of items. I want this count to remain static and locked in place, so that no matter what other columns are sorted, it still displays 1..n. I set the column bSortable:false, but I'm curious if there is a way to prevent it from being rearranged when other elements are sorted?

Replies

  • allanallan Posts: 63,498Questions: 1Answers: 10,470 Site admin
    Hi int,

    The basic answer is, no there isn't a way of having one column which won't change it's sorting order, since DataTables sorting will move the entire row around, not just cells. Having said that, one way around this would be to update the column whenever sorting occurs (using fnUpdate). It would probably be best to do this in the fnDrawCallback function, and whenever that is called, just update the values in that column to match what they now should be. There are some tricks you could try for optimising this so it only occurs when sorting has occurred (there isn't currently a sorting only callback function).

    Regards,
    Allan
This discussion has been closed.