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
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.
Ross
the Telerik team
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
"51451,63257,78941" is not contained in "51451"
"51451" contains "51451"
Everything works just fine.
Ross
the Telerik team
Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>
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
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.
Ross
the Telerik team
Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>
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
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
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
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