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

User input and FilterItem.Value for IsContainedIn operator

10 Answers 519 Views
DataFilter
This is a migrated thread and some comments may be shown as answers.
Mari Slagboom
Top achievements
Rank 1
Mari Slagboom asked on 26 Apr 2011, 03:52 PM
For a string column I can select the IsContainedIn operator.
What does the user input look like in this case? Comma seperated values?
What do I get in the FilterItem.Value? the same comma seperated list?

I can guess how it can work, but did not find a description or example of this.

Thanks in advance for any answers or pointers.

Regards,

Mari

10 Answers, 1 is accepted

Sort by
0
Rossen Hristov
Telerik team
answered on 26 Apr 2011, 04:49 PM
Hello Mari Slagboom,

It is just another string. It can be anything, including a comma separated list. But is does not have to.

We simply use the .NET string.Contains() method. We only swap the left and the right string when the operator is IsContainedIn. In other words the end-user entry goes to the left and the actual row value goes to the right.

For example "John" IsContainedIn "John is a person." 

Conversely, "John is a person." Contains "John"

So if your data value is "Mary" and the operator is IsContainedIn, if your end user enters the string "Susan, Mary, Elizabeth" then the filter will return true because the string "Susan, Mary, Elizabeth".Contains("Mary").
And so on. It's the .NET Framework that does all of this.

The left parts (in bold) are the actual data (DB) values and the right parts (in italic) are the filter values, i.e. what the end user enters.

I hope this helps. Let me know if you have any other questions.

Greetings,
Ross
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Hasse
Top achievements
Rank 1
answered on 18 Nov 2011, 11:42 AM
Hi,

I'm having problems with using the FilterOperator.IsContainedIn in a GridView. It works exactly like contains. My column has the string value of "51451" and the filter has the string value of "51451,63257,78941"  and no row show up in the grid. 'sFilter.Contains("51451")'  returns True. if i change the filter to "51451" everything works fine.


'Dim FD As New Telerik.WinControls.Data.FilterDescriptor("SendReportToContactID_string", Telerik.WinControls.Data.FilterOperator.IsContainedIn, sFilter)
                RadGridViewSendReports.FilterDescriptors.Add(FD)'


Any suggestions ?

Regard
Hasse
0
Rossen Hristov
Telerik team
answered on 18 Nov 2011, 12:46 PM
Hi Hasse,

"51451,63257,78941" is not contained in "51451"

"51451" contains "51451"

Everything works just fine.

Regards,
Ross
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

0
Hasse
Top achievements
Rank 1
answered on 21 Nov 2011, 10:02 AM
Hi Ross,

In other words the end-user entry("51451,63257,78941") goes to the left and the actual row value ("51451") goes to the right.

Public Class Form1<br><br>    Private Sub RadTextBoxFilter_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RadTextBoxFilter.TextChanged<br>        RadGridViewCust.FilterDescriptors.Clear()<br>        If RadTextBoxFilter.Text.Trim <> "" Then<br>            Dim FD As New Telerik.WinControls.Data.FilterDescriptor("ID", Telerik.WinControls.Data.FilterOperator.IsContainedIn, RadTextBoxFilter.Text)<br>            RadGridViewCust.FilterDescriptors.Add(FD)<br>        End If<br>    End Sub<br><br><br>    Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load<br><br>        RadGridViewCust.Rows.Add(New Object() {1, "51451", "Hasse"})<br>        RadGridViewCust.Rows.Add(New Object() {2, "51451", "Hasse"})<br>        RadGridViewCust.Rows.Add(New Object() {3, "51451", "Hasse"})<br>        RadGridViewCust.Rows.Add(New Object() {4, "78941", "Ross"})<br>        RadGridViewCust.Rows.Add(New Object() {5, "51451", "Hasse"})<br>        RadGridViewCust.Rows.Add(New Object() {6, "78941", "Telerik"})<br>        RadGridViewCust.Rows.Add(New Object() {7, "63257", "Ross"})<br>        RadGridViewCust.Rows.Add(New Object() {8, "51451", "Hasse"})<br>        RadGridViewCust.Rows.Add(New Object() {9, "78941", "Telerik"})<br><br>    End Sub<br>End Class

I don't get it to work. But I probaly missunderstod the use of IsContainedIn.

Regards,
Hasse
0
Rossen Hristov
Telerik team
answered on 21 Nov 2011, 10:08 AM
Hello Hasse,

IsContainedIn is the same as Contains but the left and right sides are switched.

Example 1 
Row Value = "abc"
Filter Box Value = "ab"

If you select the operator Contains you will get the row because "abc" contains "ab".
If you select the operator IsContainedIn you will not get the row because "ab" does not contain "abc".

Example 2 
Row Value = "ab"
Filter Box Value = "abc"

If you select the operator Contains you will not get the row because "ab" does not contain "abc".
If you select the operator IsContainedIn you will get the row because "abc" contains "ab".

When the operator is Contains, the row value is on the left and the filter values is on the right.
When the operator is IsContainedIn, the filter values is on the left and the row value is on the right.

I hope this helps.

Regards,
Ross
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

0
Hasse
Top achievements
Rank 1
answered on 21 Nov 2011, 10:49 AM
Hi Ross,

Exactly as I thought it would work. But it doesn't.

I noticed that I posted in a Silverlight thread when I should have posted it in the WinForms, Sorry for that.

I'm using version 2010.3.10.1215 of Telerik.WinControls.GridView.dll.

Best Regards
Hasse

0
Aaron
Top achievements
Rank 1
answered on 20 Aug 2012, 05:34 PM
Hey Ross,

I realize this thread has been inactive for a while but it seems the best place to re-hash this since is was not resolved based on the last post.

I have to agree with Hasse. The 'IsContainedIn' filter is not working as you describe it. I too have a series of the acceptable value for a given column I would like to display in the grid while hiding the the other rows. However, the values are not being found when using 'IsContainedIn'.

Per your example:

I have a grid with a column, "Type" with several available values like, "N,U,F,S,T,K"
The user should be able to select check boxes that will display only the desired types. Based on which check boxes are selected, my FilterDescriptors' value is created.

The user will select type N, U, and F, for example, and based on their selection I created a New FilterDescriptor such as
New Telerik.WinControls.Data.FilterDescriptor("Type", Telerik.WinControls.Data.FilterOperator.IsContainedIn, "N U F")


Based on your description and I would expect a row with a value of N, U, or F to be visible in the grid. As you stated this would be compared as ("N U F".Contains("N")) which is a True statement, for the "Type" column with a value of "N", and therefore should be visible .
Examples from my immediate window:
?"NUF".Contains("N")
True
?"N,U,F".Contains("N")
True
?"N U F".Contains("N")
True

Whereas, if the Descriptor were:
New Telerik.WinControls.Data.FilterDescriptor("Type", Telerik.WinControls.Data.FilterOperator.Contains, "N U F")

The compare logic would compare "N".Contains("N U F"), which is obviously False

That being said the logic does not seem to work. No Data is visible when using 'IsContainedIn' and using a string of valid values. I have tried a solid string of chars (no white space), CSV, and white space delimiters, just to make sure.

Are there issues when only using a single char as part of the compare? Or am I not understanding how this compare is supposed to be working? Any help would be greatly appreciated.


I am working with Q2 from 2011

As a sidenote I know the grid is working and other filters for the same column do work and show valid results

Thanks
0
Aaron
Top achievements
Rank 1
answered on 20 Aug 2012, 07:38 PM
So, after reviewing the expression that is used it would appear the filter uses IN (value). So, when I set up my acceptable values, "N,U, and F" in a string the expression reads "Type IN ('N U F'). Therein lies the problem as I see it. N U F is technically single value. That is why is seem to only work like contains. there is only one value set between the single quotes. In reality, this expression should read Type IN ('N','U','F'). This would be acceptable for comparing  3 separate values. Unfortunately, I cannot submit the single quotes myself, ie 'N','U','F'. The Logic still wraps this value to read ('''N'',''U'',''F''') again this is only a single valid value search.

I see that Hasse was using a slightly older version than I am but this still appears to be a problem. Did the logic change from using String.Contains? How can I pass in the 3 distinct values for the IsContainedIn logic?  If I need to start a new Forum thread I will be more than happy to. Please let me know

Thanks
0
Aaron
Top achievements
Rank 1
answered on 20 Aug 2012, 09:46 PM
The current workaround I have been using for anyone facing similar issues is to use the CompositeFilterDescriptor.

Dim compositeFilter As New Telerik.WinControls.Data.CompositeFilterDescriptor()
            compositeFilter.LogicalOperator = Telerik.WinControls.Data.FilterLogicalOperator.Or
 
compositeFilter.FilterDescriptors.Add(New Telerik.WinControls.Data.FilterDescriptor("Type", Telerik.WinControls.Data.FilterOperator.IsEqualTo, "N"))
compositeFilter.FilterDescriptors.Add(New Telerik.WinControls.Data.FilterDescriptor("Type", Telerik.WinControls.Data.FilterOperator.IsEqualTo, "U"))
compositeFilter.FilterDescriptors.Add(New Telerik.WinControls.Data.FilterDescriptor("Type", Telerik.WinControls.Data.FilterOperator.IsEqualTo, "F"))
 
RadGridView.FilterDescriptors.Add(compositeFilter)

By setter the logical Operator to 'OR' and creating several FilterDescriptors with CompositeFilterDescription. I got the result I would have expected with with a single FilterDescriptor using IsContainedIn. I hope there is a simpler solution or that the issue previously mention is resolved
0
Saurabh
Top achievements
Rank 1
answered on 24 Feb 2014, 05:00 PM
I see this is still an issue which hasn't been resolved. The workaround wouldn't work for me, as I need to change the filter value dynamically. I am using Telerik WPF UI version 2013.3.1316.40
Tags
DataFilter
Asked by
Mari Slagboom
Top achievements
Rank 1
Answers by
Rossen Hristov
Telerik team
Hasse
Top achievements
Rank 1
Aaron
Top achievements
Rank 1
Saurabh
Top achievements
Rank 1
Share this question
or