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

Contains filter for Integer Column

1 Answer 160 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Dheeraj
Top achievements
Rank 1
Dheeraj asked on 01 Jul 2010, 06:32 AM
Hi,
       I have bit unusual requirement. I have to apply "contains" as default filter for an Integer data type column( with AutoPostBackOnFilter="true").

Please help me regarding this.

Regards,
Dheeraj

1 Answer, 1 is accepted

Sort by
0
Martin
Telerik team
answered on 06 Jul 2010, 07:53 AM
Hello Dheeru y,

One option to accomplish the desired functionality is to use the approach described in this help article:

Custom option for filtering (FilterListOptions -> VaryByDataTypeAllowCustom)

Here are some sample code snippets:

<telerik:GridBoundColumn DataField="MyIntegerColumn" UniqueName="MyIntegerColumn" HeaderText="MyIntegerColumn" FilterListOptions="VaryByDataTypeAllowCustom"
               AutoPostBackOnFilter="true" ShowFilterIcon="false" CurrentFilterFunction="Custom">
</telerik:GridBoundColumn>

Code behind:

protected void RadGrid1_ItemCommand(object source, GridCommandEventArgs e)
{
    if (e.CommandName == RadGrid.FilterCommandName)
    {
        Pair filterPair = (Pair)e.CommandArgument;
        if (filterPair.First.ToString() == "Custom")
        {
            e.Canceled = true;
 
            //Filter the data source here
 
            RadGrid1.Rebind();
        }
    }
}

I hope this helps

Regards,
Martin
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
Dheeraj
Top achievements
Rank 1
Answers by
Martin
Telerik team
Share this question
or