radFilter change Expression Field Name

3 posts, 0 answers
  1. rik butcher
    rik butcher avatar
    106 posts
    Member since:
    Jul 2009

    Posted 16 Aug 2011 Link to this post

    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. Mira
    Admin
    Mira avatar
    1124 posts

    Posted 19 Aug 2011 Link to this post

    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.

  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. rik butcher
    rik butcher avatar
    106 posts
    Member since:
    Jul 2009

    Posted 19 Aug 2011 Link to this post

    Mira - thank u so much - works perfectly.
    rik
Back to Top