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

radFilter change Expression Field Name

2 Answers 104 Views
Filter
This is a migrated thread and some comments may be shown as answers.
rik butcher
Top achievements
Rank 1
rik butcher asked on 16 Aug 2011, 03:44 PM
this is an almost perfect solution except when there are more than one fieldName on the page.i add the 1st one and put in a value in the text field - so far so good.
add the 2nd one & changed the Filter Expression - it changes the expression on the top one and clears the text box. i sort of underStand why it's doing that, but what i don't know is how to tell it which one i'm on.
for instance  say, two Field Editors: Workordernumber & PoNumber.(in that order)
i create one: workordernumber & put in a value.
then create another & when i change from workordernumber to PoNumber on the 2nd one, it changes the 1st one at the top and blanks out the Value previously put in. it's performing the RecreateControl on the wrong one.....or rather, not the one i intended. how could i limit the "ChangeExpression" to the one that's being change.
thanks again for any help
rik

 

 

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();

}

 

 

else if (e.CommandName == RadFilter.ChangeExpressionFieldNameCommandName)

 

{

 

 

string myCmdArg = e.CommandArgument.ToString();

 

 

 

if (myCmdArg != "WOTYPENAME" & myCmdArg != "STATUS_MESSAGE" & myCmdArg != "MATERIALTYPE" & myCmdArg != "CREATEDDATE")

 

{

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);

WorkOrdersRadFilter.RecreateControl();

}

}

}

2 Answers, 1 is accepted

Sort by
0
Mira
Telerik team
answered on 19 Aug 2011, 09:35 AM
Hello Rik,

Please try using the following code in order to implement the desired functionality:
protected void RadFilter1_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);
        RadFilter1.RecreateControl();
    }
    else if (e.CommandName == RadFilter.ChangeExpressionFieldNameCommandName)
    {
        string myCmdArg = e.CommandArgument.ToString();
        if (myCmdArg != "WOTYPENAME" & myCmdArg != "STATUS_MESSAGE" & myCmdArg != "MATERIALTYPE" & myCmdArg != "CREATEDDATE")
        {
            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.ItemIndex;
            e.ExpressionItem.OwnerGroup.Expression.Expressions.RemoveAt(i);
            e.ExpressionItem.OwnerGroup.Expression.Expressions.Insert(i, item);
            RadFilter1.RecreateControl();
        }
    }
}

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.

0
rik butcher
Top achievements
Rank 1
answered on 19 Aug 2011, 12:48 PM
Mira - thank u so much - works perfectly.
rik
Tags
Filter
Asked by
rik butcher
Top achievements
Rank 1
Answers by
Mira
Telerik team
rik butcher
Top achievements
Rank 1
Share this question
or