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

[Solved] Set Filter on Key Stroke for Inherited RadGrid

1 Answer 66 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Jon
Top achievements
Rank 1
Jon asked on 11 Aug 2009, 02:19 PM
Hello,

I have created a custom inherited RadGrid that I am using to set certain grid functionality such as filtering on key stroke.
I am using the following code in the inherited grid to accomplish this:

        protected override void OnInit(EventArgs e)  
        {  
            base.OnInit(e);              
 
            // filter when clicking enter  
            foreach (GridColumn col in this.Columns)  
            {  
                col.CurrentFilterFunction = GridKnownFunction.StartsWith;  
                col.AutoPostBackOnFilter = true;  
            }              
        } 


The AutoPostBackOnFilter property is recognized, but the filters always default to "Contains". It appears that the CurrentFilterFunction property is ignored.

I would like to set the CurrentFilterFunction to "StartsWith" for each filter column for the custom RadGrid AutoPostBack filtering.
Is there a way to do this?

Thanks,
Jon

1 Answer, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 12 Aug 2009, 10:40 AM
Hello Jon,

I suppose you are programatically creating your grid. If so, then you can add a PreRender event handler for the grid and set the desired properties in the event as shown below:
c#:
RadGrid1.PreRender += new EventHandler(RadGrid1_PreRender);  
 
 void RadGrid1_PreRender(object sender, EventArgs e) 
    { 
        RadGrid Grid = (RadGrid)sender; 
 
        foreach (GridColumn col in Grid.Columns) 
        { 
            col.CurrentFilterFunction = GridKnownFunction.StartsWith; 
            col.AutoPostBackOnFilter = true
        } 
        Grid.MasterTableView.Rebind(); 
    }  
 

Thanks
Shinu.
Tags
Grid
Asked by
Jon
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Share this question
or