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

Problem when using filter on a gridview

5 Answers 114 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Iheb
Top achievements
Rank 1
Iheb asked on 24 Sep 2012, 02:34 PM
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

5 Answers, 1 is accepted

Sort by
0
Rossen Hristov
Telerik team
answered on 24 Sep 2012, 03:13 PM
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.

0
Iheb
Top achievements
Rank 1
answered on 25 Sep 2012, 10:37 AM
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
0
Rossen Hristov
Telerik team
answered on 25 Sep 2012, 01:41 PM
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.

0
Iheb
Top achievements
Rank 1
answered on 25 Sep 2012, 08:05 PM
Yes. When I use AddQueryOption("$filter",MyFiler()); WCF Data Services can handel It
0
Iheb
Top achievements
Rank 1
answered on 28 Sep 2012, 03:03 PM
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')";
Tags
General Discussions
Asked by
Iheb
Top achievements
Rank 1
Answers by
Rossen Hristov
Telerik team
Iheb
Top achievements
Rank 1
Share this question
or