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

Sorting Percentage Column

3 Answers 61 Views
Grid
This is a migrated thread and some comments may be shown as answers.
JD Plagianis
Top achievements
Rank 1
JD Plagianis asked on 20 Jul 2010, 04:59 PM
I have a webpage that creates a datatable programmatically depending on options that users have chosen on different pages.  I store the table as a session variable, then when the time comes, I assign the table to the grid during NeedDataSource.  No columns are explicitly defined in the RadGrid.  One of the columns could contain a percentage value.

The problem comes when someone tries to sort this percentage column:  It seems to sort as text!  100% will show up next to 10% and be listed lower than 95%.  I read through the forums and the only remedy I found was to define the radgrid column as a percentage value.  Unfortunately, I have not explicitly defined the columns in the radgrid, so RadGrid1.MasterTableView.Columns.Count = 0 and I cannot set column X's property to percentage.

Any suggestions for how to fix my sorting problem?

3 Answers, 1 is accepted

Sort by
0
Cori
Top achievements
Rank 2
answered on 20 Jul 2010, 06:25 PM
Set the DataType of your percentage column.

Like so: DataType="System.Double". This way RadGrid knows that it should sort it numerically.

I hope that helps.
0
JD Plagianis
Top achievements
Rank 1
answered on 20 Jul 2010, 06:32 PM
Yes, but how to access that column in the radgrid to set the column's property when the column is autogenerated and not explicitly declared?
0
Accepted
Iana Tsolova
Telerik team
answered on 21 Jul 2010, 09:33 AM
Hello JD,

You can handle the ColumnCreated event for that purpose.

For more information you can check out this article.


Sincerely yours,
Iana
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Tags
Grid
Asked by
JD Plagianis
Top achievements
Rank 1
Answers by
Cori
Top achievements
Rank 2
JD Plagianis
Top achievements
Rank 1
Iana Tsolova
Telerik team
Share this question
or