This is a migrated thread and some comments may be shown as answers.

Sorting using the value of a different (hidden) column

1 Answer 80 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Clifford
Top achievements
Rank 1
Clifford asked on 02 Sep 2008, 02:51 AM
I have a GridView that displays file sizes in a friendly format (1024B = 1KB, etc.) but, as expected, the built in sort sorts alphabetically (so 201KB comes before 21KB).

The actual size (in bytes) of each file is stored in a hidden column for other purposes, and I apologize if this should be easier than I'm making it, but is there a quick and dirty way to have the friendly size column sort using the value of the actual size column without having to refactor and create a custom data type for this?

Thanks.

1 Answer, 1 is accepted

Sort by
0
Julian Benkov
Telerik team
answered on 03 Sep 2008, 12:06 PM
Hello Clifford,

You can make your Size column of type int and use CellFormatting event to change cell text:

void radGridView1_CellFormatting(object sender, CellFormattingEventArgs e) 
    if (e.CellElement.ColumnIndex == 7) 
    { 
        e.CellElement.Text = radGridView1.Rows[e.CellElement.RowIndex].Cells[e.CellElement.ColumnIndex].Value + "KB"
    } 


Sincerely yours,
Julian Benkov
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Tags
GridView
Asked by
Clifford
Top achievements
Rank 1
Answers by
Julian Benkov
Telerik team
Share this question
or