C1TrueDBGrid -- sort column by text rather than underlying value

Posted by: adam.dawes on 4 September 2018, 4:23 am EST

  • Posted 4 September 2018, 4:23 am EST

    I have a C1TrueDBGrid with a column that has been set up with a ValueItems collection. This allows me to read ID values from the database and put them into this column, and it very nicely translates them into corresponding Description values to present to the user.

    However when the user clicks the column header to sort the data in grid, the grid data ends up sorted by the ID values rather than the Descriptions. This is very confusing for the user as the data is in an apparently-random order.

    Is there a way for me to get the grid to sort by the Description values rather than the underlying ID values?

  • Posted 5 September 2018, 3:26 am EST

    Hi,

    TrueDbGrid sorts the underlying data and there is no direct way to apply a custom sort.

    However, you can sort based on the text value of a column if you add the mapped column to the grid’s bound table.

    You can handle HeadClick event and set Sort property of DataView if the mapped column’s header is clicked.

    I’ve attached a sample implementing this scenario for your reference.

    Regards.

    SortValueItemDisplayValue.zip

Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels