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

Radgrid filtering with contains on numbers

3 Answers 102 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Alexander
Top achievements
Rank 1
Alexander asked on 07 Aug 2014, 03:41 PM
I have noticed a weird issue while attempting to filter columns. Particularly columns that contain numbers. For example, I have a column called ID and there is an entry in the grid with the ID 1234. When filtering with contains on the ID column, if I type 123 into the filter box, and hit enter to run it, it will turn up nothing, or an ID thats exactly 123. ID 1234 will NOT show unless I try filtering on 1234.

I am wondering if there is a way around this at all.

I have the CurrentFilterFunction="Contains" on.

<telerik:GridBoundColumn DataField="IncidentID" HeaderText="Incident ID" HeaderStyle-ForeColor="White" ShowFilterIcon="false" AutoPostBackOnFilter="true"
            SortExpression="IncidentID" ItemStyle-VerticalAlign="Top">

This is the column in question.
I have the ShowFilterIcon set to false as I only want the filter to be Contains.

I have an idea to make the bound column into a templatecolumn and populate the item in the behind code. I could make the item into a string, and filter on contains then. But I was hoping there would be a better way to do this.

3 Answers, 1 is accepted

Sort by
0
Alexander
Top achievements
Rank 1
answered on 07 Aug 2014, 03:48 PM
If anyone's wondering, converting it to a string in the backend does work. However, I really would rather have this in the front end rather than backend.

Any help is appreciated!
0
Alexander
Top achievements
Rank 1
answered on 07 Aug 2014, 04:22 PM
[quote]Alexander said:If anyone's wondering, converting it to a string in the backend does work. However, I really would rather have this in the front end rather than backend.
[/quote]

When I wrote this, I didn't actually test the filter. I just looked to see if it had the Contains ability. While it does have the Contains filtering ability, it does not work as there is no DataField. Unfortunately if you add a DataField, it will treat the column as an integer again. Back to square one!
0
Alexander
Top achievements
Rank 1
answered on 07 Aug 2014, 06:15 PM
DataType="System.String"


Is the way to go about changing this. Added this to my bound columns and it worked like a charm!
Tags
Grid
Asked by
Alexander
Top achievements
Rank 1
Answers by
Alexander
Top achievements
Rank 1
Share this question
or