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

RadGrid contains filter on integer column while preserving sorting functionability

2 Answers 415 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Alexander
Top achievements
Rank 1
Alexander asked on 22 Sep 2014, 10:07 PM
I have a RadGrid with a numbers column that is filterable and sortable. While the column's datatype is set to integer, there is no filtering function for contains. It is just set for 'exact'. The way I figured out how to get around this is to change the column's datatype to a string. The filtering then functions perfectly.

The sorting, however, breaks. If the numbers have different lengths, it raises an issue.

Here's a quick example: You have three numbers: 100, 70, 400.
Sorting ascending as per integer column: 70, 100, 400.
Sorting ascending as per string column: 100, 400, 70.

Is there a way for me to have the filtering capabilities of a string column while preserving the sorting of the integer column?

2 Answers, 1 is accepted

Sort by
0
Accepted
Radoslav
Telerik team
answered on 25 Sep 2014, 07:19 AM
Hello Alexander,

Unfortunately this is not supported scenario the filtering and paging depend on the data type and we cannot force data type to be changed dynamically. However to achieve the desired functionality you can try adding additional field into the datasource which is with Integer type. Then add this field as a sort expression of the column which is with string type. In this way when filtering will be applied over the string and when sorting is allayed the data will be sorted as integer. For example:
<telerik:GridBoundColumn DataField="Item" DataType="System.String" HeaderText="Item" SortExpression="Item1"></telerik:GridBoundColumn>

Please give it try and let me know if it helps you.

Regards,
Radoslav
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
0
Alexander
Top achievements
Rank 1
answered on 25 Sep 2014, 04:56 PM
That worked perfectly Radoslav! Thank you so much!
Tags
Grid
Asked by
Alexander
Top achievements
Rank 1
Answers by
Radoslav
Telerik team
Alexander
Top achievements
Rank 1
Share this question
or