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
610
Initial Sort Direction
posted

When an user click the header for a column that isn't sorted, it initially will sort ascending, but depending on the business context, that doesn't always make sense. The only way I've found to handle this is a hackish chunk of code from 2009 or so. http://www.infragistics.com/community/forums/t/14674.aspx

Have more recent versions of ultragrid made this easier, or is that post still the best way to handle this situation?

One option I've been contemplating is writing an IComparer that's intentionally wrong to trick the column into sorting descending instead of ascending and using that as the column's sort comparer. Would that possibly be a better alternative (or at least an acceptable alternative) to the post I linked to? Any gotchas I might hit?

Parents
No Data
Reply
  • 23930
    Offline posted

    Hello Jeffrey,

     

    One alternative approach is to use the MouseClick event to check if the user clicked on the header and if he/she did, to check what the sort indicator is. If it is Sortindicator.None you can change it to SortIndicator.Ascending. That way you will sort the column in an ascending order from the event. After that the grid will sort the column again, because of the HeaderClickAction. The end result will be that the grid column is sorted in a descending order.

     

    I have attached a sample which demonstrates this suggestion.

     

    Feel free to let me know if you have any additional questions.

    SortColumnsDesc.zip
Children
No Data