Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
425
Special sorting for hidden cells
posted

I have a grid whose datasource is set to a list of objects. In the InitializeRow event, I am checking the value of each initialized row's object, and if that condition is true, then I am setting the hidden property on 3 cells to be true. When I try to sort or filter those columns with the hidden cells, they sort/filter as if the values were still there. Is there a way to treath these cells as if they contain nothing when sorting/filtering?

Parents
  • 469350
    Verified Answer
    Offline posted

    Hi,

    There are a couple of ways you could acheive this.

    1) You could write your own SortComparer for the column which takes the Hidden state of the cell into account. That would take care of sorting. For filtering, you would also have to handle the FilterRow event and evaluate the row against the filter, once again taking the hidden state of the cell into account.

    2) Another approach, which is a little more work, but probably more reliable in the long run would be to hide the actual column of data and create an unbound column to display to the user. You would use the InitializeRow event to copy the value from the "real" column into the unbound column and in the case where the cell is hidden, you could write a null into the unbound cell. This way, when the user sorts or filters the unbound column, the grid handles everything for you since the value of the cell they are actually dealing with is null.

Reply Children