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

[Solved] Filtering a column using DataFormatString

1 Answer 220 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Jake
Top achievements
Rank 1
Jake asked on 19 Aug 2009, 05:13 PM
I have several columns in a instance of RadGrid using a DataFormatString to display currency with the decimal values removed (i.e. {0:c0}).

When a user attempts to filter on any of these columns using the "Equals" filter option, nothing is returned.  I presume this is because the underlying data contains the decimal values which is what RadGrid is filtering on.

Is there a recommended way of handling this scenario?

1 Answer, 1 is accepted

Sort by
0
Veli
Telerik team
answered on 21 Aug 2009, 10:21 AM
Hello Jake,

You are right in your presumption. RadGrid converts the filter values to double and searches for the exact value in the data source. If you have decimal digits cut off in the filtered value, your filtered and compared values do not match.

You will need to implement custom filtering for RadGrid if you want to filter by truncated field values. You can use RadGrid's ItemCommand event:

void RadGrid1_ItemCommand(object source, GridCommandEventArgs e) 
    if (e.CommandName == RadGrid.FilterCommandName) 
    { 
        e.Canceled = true
 
        // implement your custom filtering here 
 
        //RadGrid's data source should not contained the custom filtered data 
        RadGrid1.Rebind(); 
    } 


All the best,
Veli
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
Tags
Grid
Asked by
Jake
Top achievements
Rank 1
Answers by
Veli
Telerik team
Share this question
or