thanks
rik
<
telerik:RadFilter ID="RadFilter1" runat="server">
<FieldEditors>
<telerik:RadFilterTextFieldEditor FieldName="WORKORDERNUMBER" DisplayName="Work Order#" DataType="System.String" />
<telerik:RadFilterTextFieldEditor FieldName="TRACKINGNUMBER" DisplayName="Tracking#" DataType="System.String" />
</FieldEditors>
</telerik:RadFilter>
8 Answers, 1 is accepted
any help would be appreciated.
thx
rik
protected void WorkOrdersRadFilter_ItemCommand(object sender, RadFilterCommandEventArgs e)
{
if (e.CommandName == RadFilter.AddExpressionCommandName)
{
e.Canceled =
true;
RadFilterContainsFilterExpression item = new RadFilterContainsFilterExpression("StartsWith");
(e.ExpressionItem
as RadFilterGroupExpressionItem).Expression.AddExpression(item);
WorkOrdersRadFilter.RecreateControl();
}
}
thx
rik
I see that you are not defining the FilterExpression correctly in the item command event.
If you want to hava a StartsWith function by default that you need to have a RadFilterStartsWithFilterExpression object. Also, you need to pass as parameter the FieldName and not the field function.
So, after making the corrections your ItemCommand event of the RadFilter should look like this:
protected void WorkOrdersRadFilter_ItemCommand(object sender, RadFilterCommandEventArgs e){ if (e.CommandName == RadFilter.AddExpressionCommandName) { e.Canceled = true; RadFilterStartsWithFilterExpression item = new RadFilterStartsWithFilterExpression("WORKORDERNUMBER"); (e.ExpressionItem as RadFilterGroupExpressionItem).Expression.AddExpression(item); WorkOrdersRadFilter.RecreateControl(); }}
Genti
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.
When you hit the Add Filter button the filter won't know what FilterExpression to generate unless you specify it. Also, the filter does not now for which of the FieldNames to generate the filter, unless you specify it using code.
An extension that you can make to the previous solution is to handle the situation when the ChangeExpressionFieldName happens.
i.e
protected void RadFilter1_ItemCommand(object sender, RadFilterCommandEventArgs e){ if (e.CommandName == RadFilter.AddExpressionCommandName ) { e.Canceled = true; RadFilterStartsWithFilterExpression item = new RadFilterStartsWithFilterExpression("ShipAddress"); (e.ExpressionItem as RadFilterGroupExpressionItem).Expression.AddExpression(item); RadFilter1.RecreateControl(); } else if (e.CommandName == RadFilter.ChangeExpressionFieldNameCommandName) { e.Canceled = true; RadFilterStartsWithFilterExpression item = new RadFilterStartsWithFilterExpression(e.CommandArgument.ToString()); //replace the current item with the new item that has the default filter set to StartsWith int i = e.ExpressionItem.OwnerGroup.Expression.Expressions.IndexOf((e.ExpressionItem).OwnerGroup.Expression.FindByFieldName((((RadFilterSingleExpressionItem)(e.EventSource)).Expression).FieldName)); e.ExpressionItem.OwnerGroup.Expression.Expressions.RemoveAt(i); e.ExpressionItem.OwnerGroup.Expression.Expressions.Insert(i, item); RadFilter1.RecreateControl(); }}Regards,
Genti
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.
thanks again
rik
thanks again for all of your help
rik
Unfortunately, the desired functionality is not supported.
However, you might use the following code in order to set the focus to the last rendered textbox:
protected void RadFilter1_PreRender(object sender, EventArgs e){ var ctrl = ControlsOfType<ITextControl>(RadFilter1).Where(p => p.GetType() != typeof(LiteralControl)); if (ctrl.Count() > 0) (ctrl.Last() as Control).Focus();}public IEnumerable<T> ControlsOfType<T>(Control parent) where T : class{ foreach (Control control in parent.Controls) { if (control is T) { yield return control as T; continue; } foreach (T descendant in ControlsOfType<T>(control)) { yield return descendant; } }}I hope it 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.