All,
I am using a RadFilter to do complex filtering on my RadGrid. So far this is working very well. What I can't seem to figure out is how to reapply the filter after removing an expression. Every time I remove an expression, I still get the filtered grid that included the removed expression.
I am using AllowFilterOnBlur="true" in order to reduce the amount of buttons on the page...
Any suggestions are greatly appreciated.
Thanks,
B
I am using a RadFilter to do complex filtering on my RadGrid. So far this is working very well. What I can't seem to figure out is how to reapply the filter after removing an expression. Every time I remove an expression, I still get the filtered grid that included the removed expression.
I am using AllowFilterOnBlur="true" in order to reduce the amount of buttons on the page...
Any suggestions are greatly appreciated.
Thanks,
B
5 Answers, 1 is accepted
0
Hello Bruce,
The AllowFilterOnBlur property indicates whether the RadFilter should post back when the value in the editor changes. When an expression is removed, you should either click the Apply button or call FireApplyCommand in order to refresh the datasource.
I hope this helps.
Best wishes,
Mira
the Telerik team
The AllowFilterOnBlur property indicates whether the RadFilter should post back when the value in the editor changes. When an expression is removed, you should either click the Apply button or call FireApplyCommand in order to refresh the datasource.
I hope this helps.
Best wishes,
Mira
the Telerik team
Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.
0
peaeater
Top achievements
Rank 1
answered on 13 Jul 2011, 08:32 PM
I'm in the same boat, using RadFilter against a RadGrid with AllowFilterOnBlur set to true, and trying to reapply the filter after removing an expression. The suggestion to call FireApplyCommand when an expression is removed does not work.
Following is what a debug step-through shows. When clicking the remove button, RadFilter's ItemCommand fires and I call FireApplyCommand, which merely reapplies the filter as it was before the remove button was clicked, so the RadGrid remains as it was before postback. The RadFilter's expression description is correctly reduced, though.
Using Telerik.Web.UI.dll 2011.1.413.40, .NET 4 version. The RadFilter and RadGrid are ajaxified with RadAjaxManager.
Following is what a debug step-through shows. When clicking the remove button, RadFilter's ItemCommand fires and I call FireApplyCommand, which merely reapplies the filter as it was before the remove button was clicked, so the RadGrid remains as it was before postback. The RadFilter's expression description is correctly reduced, though.
Using Telerik.Web.UI.dll 2011.1.413.40, .NET 4 version. The RadFilter and RadGrid are ajaxified with RadAjaxManager.
void
RadFilter1_ApplyExpressions(
object
sender, RadFilterApplyExpressionsEventArgs e)
{
var provider =
new
RadFilterSqlQueryProvider();
provider.ProcessGroup(e.ExpressionRoot);
PreviewFilterExpression = provider.Result;
}
void
RadFilter1_ItemCommand(
object
sender, RadFilterCommandEventArgs e)
{
if
(e.CommandName ==
"RemoveExpression"
)
{
RadFilter1.FireApplyCommand();
}
}
protected
void
RadGrid1_NeedDataSource(
object
sender, GridNeedDataSourceEventArgs e)
{
RadGrid1.DataSource = DataSource;
}
0
peaeater
Top achievements
Rank 1
answered on 13 Jul 2011, 11:05 PM
Here's a hack that is getting me by for the moment. In ItemCommand I manually remove the expression from the parent group's Expressions collection based on the ChildItems index of the ExpressionItem firing the command. I'm making the assumption the indexes are the same in both collections: so far so good.
void
RadFilter1_ApplyExpressions(
object
sender, RadFilterApplyExpressionsEventArgs e)
{
var provider =
new
RadFilterSqlQueryProvider();
provider.ProcessGroup(e.ExpressionRoot);
PreviewFilterExpression = provider.Result;
}
void
RadFilter1_ItemCommand(
object
sender, RadFilterCommandEventArgs e)
{
if
(e.CommandName ==
"RemoveExpression"
)
{
var expr = e.ExpressionItem;
var grp = e.ExpressionItem.OwnerGroup;
grp.Expression.Expressions.RemoveAt(Array.IndexOf(grp.ChildItems.ToArray(), expr));
RadFilter1.FireApplyCommand();
}
}
protected
void
RadGrid1_NeedDataSource(
object
sender, GridNeedDataSourceEventArgs e)
{
RadGrid1.DataSource = DataSource;
}
0
peaeater
Top achievements
Rank 1
answered on 13 Jul 2011, 11:43 PM
Argh. Same problems with ItemCommand when e.CommandName is "ChangeFilterFunction" when AllowFilterOnBlur is "true" and a textbox is not in play. (I.e. when e.CommandArgument is "IsNull", "NotIsNull", "IsEmpty", "NotIsEmpty".) In those cases ApplyExpressions is out of date when fired from ItemCommand. The filter that is applied is whatever was active before the postback.
For now I'm setting AllowFilterOnBlur="false" but would like to see an update that resolved this.
For now I'm setting AllowFilterOnBlur="false" but would like to see an update that resolved this.
void
RadFilter1_ApplyExpressions(
object
sender, RadFilterApplyExpressionsEventArgs e)
{
var provider =
new
RadFilterSqlQueryProvider();
provider.ProcessGroup(e.ExpressionRoot);
PreviewFilterExpression = provider.Result;
log.DebugFormat(
"RadFilter applied this expression: {0}"
, provider.Result);
}
void
RadFilter1_ItemCommand(
object
sender, RadFilterCommandEventArgs e)
{
if
(e.CommandName ==
"ChangeFilterFunction"
)
{
var arg = (
string
) e.CommandArgument;
if
(arg ==
"IsNull"
| arg ==
"IsEmpty"
| arg ==
"NotIsNull"
| arg ==
"NotIsEmpty"
)
{
// filter not updated properly here
RadFilter1.FireApplyCommand();
}
}
if
(e.CommandName ==
"RemoveExpression"
)
{
var expr = e.ExpressionItem;
var grp = e.ExpressionItem.OwnerGroup;
grp.Expression.Expressions.RemoveAt(Array.IndexOf(grp.ChildItems.ToArray(), expr));
RadFilter1.FireApplyCommand();
}
}
protected
void
RadGrid1_NeedDataSource(
object
sender, GridNeedDataSourceEventArgs e)
{
RadGrid1.DataSource = DataSource;
}
0
Hello Peter,
I have followed your scenario and prepared a sample project for you demonstrating how the desired functionality can be implemented. You can find it attached to this message.
I hope it helps.
All the best,
Mira
the Telerik team
I have followed your scenario and prepared a sample project for you demonstrating how the desired functionality can be implemented. You can find it attached to this message.
I hope it helps.
All the best,
Mira
the Telerik team
Register for the Q2 2011 What's New Webinar Week. Mark your calendar for the week starting July 18th and book your seat for a walk through of all the exciting stuff we will ship with the new release!