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

Getting FilterExpression Before Grid Bind

2 Answers 58 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Jeff
Top achievements
Rank 1
Veteran
Jeff asked on 09 Nov 2012, 03:37 PM
I have a RadGrid that gets it's data from a WCF data service that returns a DataTable. I'm using the grid's bulit in filtering ( RadFilter) amd I need to get the filter expression BEFORE the call to the data service. I can only seem to get the FilterExpression after the grid binds.

2 Answers, 1 is accepted

Sort by
0
Eyup
Telerik team
answered on 14 Nov 2012, 09:06 AM
Hello Jeff,

You could try the following approach to prevent the filter operation depending on your condition:
protected void RadGrid1_ItemCommand(object sender, GridCommandEventArgs e)
{
    if (e.CommandName == RadGrid.FilterCommandName)
    {
        Pair filterData = e.CommandArgument as Pair;
        string filterFunction = filterData.First.ToString();
        string filteredColumn = filterData.Second.ToString();
        string filterValue = RadGrid1.MasterTableView.GetColumnSafe(filteredColumn).CurrentFilterValue;
        if (true) //custom condition
        {
            e.Canceled = true;
        }
    }
}

I hope this will prove helpful. Please give it a try and let me know about the result.

All the best,
Eyup
the Telerik team
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.
0
Jeff
Top achievements
Rank 1
Veteran
answered on 14 Nov 2012, 01:09 PM
What I ended up doing which works is the following. 

In the RadToolBar_ButtonClick event I execute 
        RadFilter.FireApplyCommand(); 

That sets the filter string because now I can get the the filtering expression with RadGrid.MasterTableView.FilterExpression in my method that gets the data but before the actuall call to get the data. Which is what I was looking for.
Tags
Grid
Asked by
Jeff
Top achievements
Rank 1
Veteran
Answers by
Eyup
Telerik team
Jeff
Top achievements
Rank 1
Veteran
Share this question
or