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

How is filtering applied to RadGrid?

3 Answers 231 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Sean Severson
Top achievements
Rank 1
Sean Severson asked on 21 May 2013, 08:33 PM
Hello,

I am working to better understand how filtering is applied to the RadGrid and if I can determine if an item in the grid will be visible or not (due to a filter being applied) in the ItemDataBound event.   Could someone point me to documentation that explains how filters are applied and the various events I could use to either determine what is being filtered or affect what will be filtered?

My specific use for this is to generate a unique list of items in a specific column in the grid after the filter is applied.  I have determined that the ItemDataBound event fires when a filter will be applied, but have been unable to detemine how the filter is applied or if there is an event exposed to me that would allow me to see this.

Thanks,

Sean Severson

3 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 22 May 2013, 06:05 AM
Hello Sean Severson,

I am not sure of your requirements.Please check this to see if this helps.
This code shows how to access the currently filtering column and the filter function being used.

C#:
protected void RadGrid1_ItemCommand(object sender, GridCommandEventArgs e)
{
    if (e.CommandName == RadGrid.FilterCommandName)
    {
        Pair filterPair = (Pair)e.CommandArgument;
        String pair = filterPair.First.ToString(); //Gets the Filter function
        String pair1 = filterPair.Second.ToString(); //Gets the Filter Column
    }
 
}

Thanks,
Shinu
0
Sean Severson
Top achievements
Rank 1
answered on 23 May 2013, 06:44 PM
Shinu,

Thank you for the code.  However, I am looking for an explenation of when and how the filter is applied.  For example, does the RadGrid spin through all of the records in its datasource and check the records against the filter properties to determine if the record should be displayed and, if not, skip over it?  In what event does this occur?  Can I tap into that event in order to perform some processing for each row that should/should not be displayed?

Thanks.

Sean Severson
0
Eyup
Telerik team
answered on 28 May 2013, 07:31 AM
Hi Sean,

When the users initiates a filter command, RadGrid builds the FilterExpression for each column and makes a query to the datasource and displays only the returned items. Therefore, the grid rebinds internally every time when filtering is applied, which fires the ItemDataBound event.

I have attached a sample RadGrid web site demonstrating how you can determine whether a column has been filtered. Please check out the attached application and let me know if it helps you.

Regards,
Eyup
Telerik
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
Tags
Grid
Asked by
Sean Severson
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Sean Severson
Top achievements
Rank 1
Eyup
Telerik team
Share this question
or