Problem when using filter on a gridview

6 posts, 0 answers
  1. Iheb
    Iheb avatar
    12 posts
    Member since:
    Sep 2012

    Posted 24 Sep 2012 Link to this post

    I have loaded the data of the grid view page per page like in the demo: http://demos.telerik.com/silverlight/#DataServiceDataSource/MVVM and it works great.

    But I need to do a custom query so I modified a line in the view model like this: 
    DataServiceQuery<Order> ordersQuery = this.ordersContext.Orders.AddQueryOption("$filter",MyFiler());

    where MyFilter is a function that returns a string: for example it can returns :" ID_CLIENT gt 200"

    The problem is when I add this the filter of the gridView won't work anymore
  2. Rossen Hristov
    Admin
    Rossen Hristov avatar
    2478 posts

    Posted 24 Sep 2012 Link to this post

    Hello,

    You can add a FilterDescriptor with this condition.

    Greetings,
    Ross
    the Telerik team

    Time to cast your vote for Telerik! Tell DevPro Connections and Windows IT Pro why Telerik is your choice. Telerik is nominated in a total of 25 categories.

  3. DevCraft banner
  4. Iheb
    Iheb avatar
    12 posts
    Member since:
    Sep 2012

    Posted 25 Sep 2012 Link to this post

    I tried to use the FilterDescriptor and the CompositeFilterDescriptor but it seems that it can't handle long request. 

    The following code don't work
    CompositeFilterDescriptor compositeDescriptorCommercOr = new CompositeFilterDescriptor();
    compositeDescriptorCommercOr.LogicalOperator = FilterCompositionLogicalOperator.Or;
     
    foreach (var numCommerc in ConvertFromFormattedStringToList("('0','55','54','53','52','50','49','48','47','44','42','39','38','33','32','31','29','28','27','26','25','24','23','22','20','18','17','16','15','14','13','12','11','9','8','7','6','5','4','3','2','991','992','57','58','63','70','71')"))
    {
                compositeDescriptorCommercOr.FilterDescriptors.Add(new FilterDescriptor() { Member = "COMMERC", Operator = FilterOperator.IsEqualTo, Value = numCommerc });
    }
    radGridView.FilterDescriptors.Add(compositeDescriptorCommercOr);

    But the following work
    CompositeFilterDescriptor compositeDescriptorCommercOr = new CompositeFilterDescriptor();
    compositeDescriptorCommercOr.LogicalOperator = FilterCompositionLogicalOperator.Or;
     
    foreach (var numCommerc in ConvertFromFormattedStringToList("('0','55','54','53')"))
    {
                compositeDescriptorCommercOr.FilterDescriptors.Add(new FilterDescriptor() { Member = "COMMERC", Operator = FilterOperator.IsEqualTo, Value = numCommerc });
    }
    radGridView.FilterDescriptors.Add(compositeDescriptorCommercOr);

    Where ConvertFromFormattedStringToList convert the string passed on parameter to a list of int
  5. Rossen Hristov
    Admin
    Rossen Hristov avatar
    2478 posts

    Posted 25 Sep 2012 Link to this post

    Hi,

    Can WCF Data Services handle a request of the same length if your were not using any Telerik controls at all?

    Greetings,
    Ross
    the Telerik team

    Time to cast your vote for Telerik! Tell DevPro Connections and Windows IT Pro why Telerik is your choice. Telerik is nominated in a total of 25 categories.

  6. Iheb
    Iheb avatar
    12 posts
    Member since:
    Sep 2012

    Posted 25 Sep 2012 Link to this post

    Yes. When I use AddQueryOption("$filter",MyFiler()); WCF Data Services can handel It
  7. Iheb
    Iheb avatar
    12 posts
    Member since:
    Sep 2012

    Posted 28 Sep 2012 Link to this post

    Finally, I found a bypass for that.

    If I use this it tell me that contains is not support by OData 

    descriptor2.Member = "COMMERC_INT";
    descriptor2.Operator = FilterOperator.IsContainedIn;
    descriptor2.Value = new int[] { 0,55,54,53,52,50,49,48,47,44,42,39,38,33,32,31,29,28,27,26,25,24,23,22,20,18,17,16,15,14,13,12,11,9,8,7,6,5,4,3,2,991,992,57,58,63,70,71)};

    But when I use this and it works and it wont bug even when I filter the colum of the primary key( unless I use the select all check box)

    descriptor2.Member = "COMMERC_STRING";
    descriptor2.Operator = FilterOperator.IsContainedIn;
    descriptor2.Value = "('0','55','54','53','52','50','49','48','47','44','42','39','38','33','32','31','29','28','27','26','25','24','23','22','20','18','17','16','15','14','13','12','11','9','8','7','6','5','4','3','2','991','992','57','58','63','70','71')";
Back to Top
DevCraft banner