In and NotIn

7 posts, 0 answers
  1. moegal
    moegal avatar
    273 posts
    Member since:
    Jul 2007

    Posted 05 Apr 2013 Link to this post

    I want to create a custom RadFilter

    I want to show a dropdown(combo) but have the choices be IN or NotIN I would actually call them "In Order" and "Not In Order"

    my data would look like the following.

    orderID | OrderDate | ProductList
    123456   04/01/2013   15,16,17,18,19

    here is an image of what I am trying to do.


  2. Antonio Stoilkov
    Admin
    Antonio Stoilkov avatar
    530 posts

    Posted 10 Apr 2013 Link to this post

    Hi Marty,

    You could achieve your scenario by creating a custom RadFilter editor as shown in the help article and demo below.

    Additionally, you could modify the menu options by following the help article below and the sample code provided below.
    function pageLoad(sender, args)
    {
        var filter = $find("<%=RadFilter1.ClientID %>");
        var menu = filter.get_contextMenu();
        menu.add_showing(FilterMenuShowing);
     
        var elements = document.getElementsByTagName("a");
        for (var i = 0; i < elements.length; i++)
        {
            if (elements[i].className && elements[i].className.indexOf("rfExp") != -1 &&
                elements[i].innerHTML == "EqualTo")
            {
                elements[i].innerHTML = "In Order";
            }
            else if (elements[i].className && elements[i].className.indexOf("rfExp") != -1 &&
                elements[i].innerHTML == "NotEqualTo")
            {
                elements[i].innerHTML = "Not In Order";
            }
        }
    }
     
    function FilterMenuShowing(sender, args)
    {
        sender.findItemByValue("EqualTo").set_text("In Order");
        sender.findItemByValue("NotEqualTo").set_text("Not In Order");
    }

    Regards,
    Antonio Stoilkov
    the Telerik team
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. moegal
    moegal avatar
    273 posts
    Member since:
    Jul 2007

    Posted 10 Apr 2013 Link to this post

    Antonio,

    thanks for the reply.

    I already have been working on the interface part of the filter(Botheof the links you sent are what I have been working off of). How can I tell the query to select a value inside of the returned value?

    my datasource and/or grid will have a record like the following:

    ProductList
    15,16,17,18,19

    so my resulting filter would return 16 =  15,16,17,18,19

    If I were using an operator of EqualTo then 16 would not work. Productlist in this case is  15,16,17,18,19.   I need something more like the sql IN operator. Contains would not really work either because I could have values like 15,168,177 so 16 would return true if I used contains. But it should not.

    Thanks, Marty
  5. Antonio Stoilkov
    Admin
    Antonio Stoilkov avatar
    530 posts

    Posted 15 Apr 2013 Link to this post

    Hi Marty,

    In order to achieve your scenario you could use a Contains which is for your example ProductList 15, 16, 17, 18, 19 which could be Contains "15, " OR Contains ", 15". Note that we are currently working on improving RadFilter API so these kind of operations are easier to achieve. However, currently you should manually swap each of the Contains expression for two Contains expressions as described above in the ApplyExpressions event and applying the technique shown in the help topic below.

    Regards,
    Antonio Stoilkov
    the Telerik team
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
  6. moegal
    moegal avatar
    273 posts
    Member since:
    Jul 2007

    Posted 15 Apr 2013 Link to this post

    Antonio,

    thanks.  that may work.  Can you point me to a RadFilterSqlQueryProvider example.  Not sure I follow on how to replace one "contains" expression with 2 "contains" as you have explained.

    Marty
  7. Antonio Stoilkov
    Admin
    Antonio Stoilkov avatar
    530 posts

    Posted 18 Apr 2013 Link to this post

    Hi Marty,

    I have assembled a sample page showing the desired functionality implemented. The idea is to subscribe to RadGrid ApplyExpressions event and for every RadFilterContainsFilterExpression replace it with two RadFilterContainsFilterExpression.
    protected void RadFilter1_ApplyExpressions(object sender, Telerik.Web.UI.RadFilterApplyExpressionsEventArgs e)
    {
        RadFilterGroupExpression rootGroupClone = new RadFilterGroupExpression();;
        for (int i = 0; i < RadFilter1.RootGroup.Expressions.Count; i++)
        {
            RadFilterContainsFilterExpression containsExpression = RadFilter1.RootGroup.Expressions[i] as RadFilterContainsFilterExpression;
            if (containsExpression != null && !containsExpression.Value.Contains(','))
            {
                RadFilterContainsFilterExpression first = new RadFilterContainsFilterExpression(containsExpression.FieldName);
                first.Value = containsExpression.Value + ", ";
                RadFilterContainsFilterExpression second = new RadFilterContainsFilterExpression(containsExpression.FieldName);
                second.Value = ", " + containsExpression.Value;
                     
                RadFilterGroupExpression group = new RadFilterGroupExpression();
                group.AddExpression(first);
                group.AddExpression(second);
                group.GroupOperation = RadFilterGroupOperation.Or;
     
                rootGroupClone.AddExpression(group);
            }
            else
            {
                rootGroupClone.AddExpression(RadFilter1.RootGroup.Expressions[i]);
            }
        }
     
        RadFilterDynamicLinqQueryProvider provider = new RadFilterDynamicLinqQueryProvider();
        provider.ProcessGroup(rootGroupClone);
        Response.Write(provider.Result);
    }

    Kind regards,
    Antonio Stoilkov
    the Telerik team
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
  8. moegal
    moegal avatar
    273 posts
    Member since:
    Jul 2007

    Posted 18 Apr 2013 Link to this post

    I will check it out, thanks Antonio.

    Marty
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017