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
340
Click an ultragrid's one column header to sort by another
posted

hi,

let's say we have the following columns:

account name (ex: Mega Design) << string

created on (ex: 15) << integer

description (ex: 15 days ago) << string

if we click on account name column header, the grid sorts the column asc/desc according to its datatype (in this case string).

if we click on (description) column header, it will will sort the column as a string (15 days ago).

now, i want to hide (created on) column and keep (account name, description)

and make clicking on description sorts the grid as an integer...as if we have clicked on (created on)).

is that possible?

Parents
No Data
Reply
  • 469350
    Suggested Answer
    Offline posted

    Hi, 

    Yes, this is actually pretty easy. There is a SortComparer property on the UltraGridColumn. So this allows you to customize the sorting of any column however you want. In this case, it's even easier, because you aren't doing any complex sorting, you just want to re-direct the sorting of one column to use the values from another column.

    I have attached a small sample project that sorts a string column ("String 1") by the value of an integer column ("Int32 1").

    MemDataTable CS.zip
Children