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

IColumnFilterDescriptor problem when twho different items are on the same level

6 Answers 105 Views
GridView
This is a migrated thread and some comments may be shown as answers.
ASSYST2 - CGI
Top achievements
Rank 1
ASSYST2 - CGI asked on 01 Apr 2014, 10:26 AM
Hello,

I am having some problems on our solution with the IColumnFilterDescriptor.

Here is our C# implementation :

private void searchTextbox_KeyDown(object sender, KeyEventArgs e)
       {
           if (e.Key == Key.Enter) // Enter key pressed
           {
               this.treeListView.FilterDescriptors.Clear();
               var searchTextBox = (TextBox)sender;
 
               if (!string.IsNullOrWhiteSpace(searchTextBox.Text))
               {
                   //this.treeListView.FilterDescriptors.SuspendNotifications();
 
                   if (this.FilterColumns.Count() < 2)
                   {
                       var filterColumn = this.treeListView.Columns[0];
                       filterColumn.ClearFilters();
                       IColumnFilterDescriptor columnDescriptor = filterColumn.ColumnFilterDescriptor;
                       columnDescriptor.FieldFilter.Clear();
 
                       if (!string.IsNullOrWhiteSpace(searchTextBox.Text))
                       {
                           columnDescriptor.SuspendNotifications();
                           columnDescriptor.FieldFilter.Filter1.Operator = FilterOperator.Contains;
                           columnDescriptor.FieldFilter.Filter1.Value = searchTextBox.Text.Trim();
                           columnDescriptor.FieldFilter.Filter1.IsCaseSensitive = false;
 
                           if (columnDescriptor.FieldFilter.Filter2 != null)
                           {
                               columnDescriptor.FieldFilter.Filter2.Operator = FilterOperator.IsNotNull;
                               columnDescriptor.FieldFilter.Filter2.Value = null;
                           }
                           try
                           {
                               columnDescriptor.ResumeNotifications();
                           }
                           catch (ArgumentException) { }
                       }
                   }
                   else
                   {
                       CompositeFilterDescriptor compositeDescriptor = new CompositeFilterDescriptor();
                       compositeDescriptor.LogicalOperator = FilterCompositionLogicalOperator.Or;
                       foreach (var column in this.FilterColumns)
                       {
                           compositeDescriptor.FilterDescriptors.Add(new FilterDescriptor(column,FilterOperator.Contains, searchTextbox.Text, false, typeof(string)));
                       }
 
                       //this.treeListView.FilterDescriptors.SuspendNotifications();
                       this.treeListView.FilterDescriptors.Add(compositeDescriptor);
                       //this.treeListView.FilterDescriptors.ResumeNotifications();
                   }
                   //this.treeListView.FilterDescriptors.ResumeNotifications();
               }
           }
       }

The problem occurs when we in the gridview, we have 2 different item types at the same level. Here is the error we are getting on the columnDescriptor.ResumeNotifications() event :
ArgumentException :
The value "(Empty) AND ((Title Contains ma) AND (Title IsNotNull null))" is not of type "Telerik.Windows.Data.IFilterDescriptor" and cannot be used in this generic collection.
Parameter name: value

We are following the examples shown on your site.
We've been trying to figure out this problem for ours without any success. Any idea where this problem comes from?



6 Answers, 1 is accepted

Sort by
0
Dimitrina
Telerik team
answered on 03 Apr 2014, 05:07 AM
Hello,

This is actually a very strange exception.

What is the result if you exclude the code lines related to columnDescriptor.FieldFilter.Filter2?

If the exception still occurs, may I ask you to isolate the issue in a demo project and send it to us? You can take a look at this blog post for a reference on how to isolate an issue. 

Regards,
Didie
Telerik
 

Build cross-platform mobile apps using Visual Studio and .NET. Register for the online webinar on 03/27/2014, 11:00AM US ET.. Seats are limited.

 
0
ASSYST2 - CGI
Top achievements
Rank 1
answered on 03 Apr 2014, 02:24 PM
What is the result if you exclude the code lines related to columnDescriptor.FieldFilter.Filter2?
We actually added it to see if it could solve it. So it doesnt change anything, we get the same error.

In order to isolate the problem and you a project, right now I can tell that we can't. We'll see if we have extra time before the end of this Sprint.
0
Dimitrina
Telerik team
answered on 04 Apr 2014, 03:46 PM
Hi,

In the ticket's title it is written that the problem occurs when "two different items are on the same level". Would you please share some more information on this?
Then, the thread is about RadGridView, but in the demo code I can see the instance is named this.treeListView.
Do you use RadGridView or RadTreeListView?

You can also check our Search As You Type WPF Demo as a reference. I cannot reproduce any issue there.

Regards,
Didie
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
0
ASSYST2 - CGI
Top achievements
Rank 1
answered on 22 Apr 2014, 04:07 PM
Hi Didie,

Thank you very much for your feedback !
To answer your second question first, indeed, we are using a RadTreeListView control and not RadGridView.

By "two different items are on the same level", I mean that we are using object instances from two different object types at the same node level (they are implementing common interfaces by the way). In order to make it clear, here is an abstract version of our scenario we use to reproduce the bug:
- A1 (instance called "1" from an object type "A")
      -- A1.1 (instance called "1.1" from an object type "A", which is a child of A1)
      -- A1.2
- A2
      -- A2.1
            --- B2.1.1
            --- B2.1.2
            --- B2.1.3
      -- A2.2
      -- B2.3
- A3

If I keep instances of the same object type at the same hierarchy level in my tree / object, it works perfectly (remove B2.3 in the example above). However, when I add an instance of an object B while having a list of A object instances, I get the error with the filter (keep the B2.3 instance in the example).

With these additional information, would you have an idea of the cause of our issue ?

Thanks in advance,
Best regards,
F.
0
Accepted
Dimitrina
Telerik team
answered on 23 Apr 2014, 01:03 PM
Hi,

So you have items of different type in your ItemsSource. Do those objects have a common base class? If yes, the you can try setting RadTreeListView.Items.ItemType to be this base type. Does this help?

Generally you need to consider using the RadTreeListView for displaying only homogeneous data. For more information you can check our online documentation on TreeListView.  


Regards,
Didie
Telerik
 
Check out Telerik Analytics, the service which allows developers to discover app usage patterns, analyze user data, log exceptions, solve problems and profile application performance at run time. Watch the videos and start improving your app based on facts, not hunches.
 
0
ASSYST2 - CGI
Top achievements
Rank 1
answered on 23 Apr 2014, 03:08 PM
Hi Didie,

Thank you so much for your help, it works like a charm!

Regards,
F.
Tags
GridView
Asked by
ASSYST2 - CGI
Top achievements
Rank 1
Answers by
Dimitrina
Telerik team
ASSYST2 - CGI
Top achievements
Rank 1
Share this question
or