RadFilter -- Show Contains as Default

9 posts, 0 answers
  1. Bill Swartz
    Bill Swartz avatar
    8 posts
    Member since:
    May 2010

    Posted 18 Apr 2011 Link to this post

    In RadFilter's compare operator dropdown, Is there a way to display Contains as Default instead of Equal to for string data types .
  2. Pavlina
    Admin
    Pavlina avatar
    6084 posts

    Posted 19 Apr 2011 Link to this post

    Hi Bill,

    To set the default expression to Contains you can use the code snippet below:
    C#:
    protected void RadFilter1_ItemCommand(object sender, RadFilterCommandEventArgs e) 
        if (e.CommandName == RadFilter.AddExpressionCommandName) 
        
            e.Canceled = true
            RadFilterContainsFilterExpression item = new RadFilterContainsFilterExpression("ColumnUniqueName"); 
            (e.ExpressionItem as RadFilterGroupExpressionItem).Expression.AddExpression(item); 
            RadFilter1.RecreateControl(); 
        
    }

    Try it out and let me know how it goes.

    Regards,
    Pavlina
    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. Bill Swartz
    Bill Swartz avatar
    8 posts
    Member since:
    May 2010

    Posted 19 Apr 2011 Link to this post

    Hi Pavlina,


    Getting Error  "Object reference not set to an instance of an object." on the line RadFilter1.RecreateControl(); 


    Thanks
  5. Bill Swartz
    Bill Swartz avatar
    8 posts
    Member since:
    May 2010

    Posted 19 Apr 2011 Link to this post

    Hi Pavlina,

       Do you've any updates on this.

    thanks
  6. Pavlina
    Admin
    Pavlina avatar
    6084 posts

    Posted 20 Apr 2011 Link to this post

    Hello Bill,

    Please find attached to this message a sample working project which handles the desired functionality. Examine it and see if it works as expected or if I am leaving something out.

    All the best,
    Pavlina
    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.

  7. Bill Swartz
    Bill Swartz avatar
    8 posts
    Member since:
    May 2010

    Posted 20 Apr 2011 Link to this post

    Hi Pavlina,
       I've 2 issues.

        1.Filter drop down shows contains as default on the screen for string datatype but when i click apply    nothing     works.         I've     attached     one.jpg     sample file herewith.
       2. While adding multiple fields, for example from your sample add country, "Contains" doesnt show as default, instead shows equal to as default
            and on top clicking apply does nothing.
  8. Bill Swartz
    Bill Swartz avatar
    8 posts
    Member since:
    May 2010

    Posted 20 Apr 2011 Link to this post


    Hi Pavlina,

    I updated Radfilter tag with  FilterContainerID="RadGrid1" , it works but different than your code.
    Without updating FilterContainerID Filter shows only 2 column names in drop down but adding FilterContainerID
    shows all the columns in the drop down and shows "contains" as default for all the column. If i add a date column, that also shows "contains" as default and the appln crashes. Can you provide me an example using Orders table with int, string,date datatypes. I need this feature to work for all datatypes.

    Thanks
  9. Pavlina
    Admin
    Pavlina avatar
    6084 posts

    Posted 26 Apr 2011 Link to this post

    Hi Bill,

    It is important to note that, if there are any field editors defined in the aspx code, these will be overridden by the settings applied by the user at runtime. Thus, the final filter expression would not reflect the pre-defined filter field editors. Please check out the help article below for more information:
    http://www.telerik.com/help/aspnet-ajax/filter-basics.html

    Regards,
    Pavlina
    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.

  10. Campus Labs
    Campus Labs avatar
    13 posts
    Member since:
    Jan 2007

    Posted 05 May 2011 Link to this post

    Bill, I worked on a similar feature a while ago. Here's the forum post with the details: http://www.telerik.com/community/forums/aspnet-ajax/filter/default-filter-function-for-custom-field-editor.aspx#1392723

    Hope that helps!
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017