How to manage or hide filter "In in list"

3 Answers 118 Views
DataFilter GridView
Giovanni
Top achievements
Rank 1
Iron
Iron
Iron
Giovanni asked on 20 Nov 2023, 09:46 AM

Hi, I'm using a RadDataFilter connected to a RaGridView.

For the string column by default is available the "Is in list" filter.

But, if I try to use it, a single textbox is showed and when the filter is applied, and the generated filter expressioin is like "[FieldName] IN 1234" where 1234 is the exaxt text I digited, without quotes.
I think I've not understand how to use this filter, so can anyone suggest to me the correct way to use it?

Alternatively, how can I remove/hide this kind of filter (I do not really need to use this filter)?



Thank you

 

3 Answers, 1 is accepted

Sort by
0
Accepted
Nadya | Tech Support Engineer
Telerik team
answered on 23 Nov 2023, 10:36 AM

Hello, Giovanni,

The IsEqualTo and IsInList  filter options may sound similar but they differ in their implementation and might be useful in different cases according to client needs. I am providing more information about the filter operators that they use and the final filtering expression as a string.

The IsEqualTo option uses the FilterOperator.IsEqualTo, and the expression looks like this: [CustomerID] = '2'.
The IsInList oprion uses FilterOperator.IsContainedIn , and the expression is "[CustomerID] IN ('2')".

According to the question about filtering only date without the time part, note that GridViewDateTimeColumn exposes a FilteringMode property which determines how the DateTime values are being filtered. Here is how you can set this property:

GridViewDateTimeColumn  dateColumn = this.radGridView1.Columns["ShippedDate"] as GridViewDateTimeColumn;
dateColumn.FilteringMode = GridViewTimeFilteringMode.Date;

More information about GridViewDateTimeColumn is available here.

As to your last questions in this post, the FilterDescriptor.FilterExpression gives you access to the filter applied in RadGridView. However, please have in mind that it uses SQL-like format but it can't be completely considered as SQL compatible. RadGridView has its own parsing logic for interpreting the filter expressions. It is improved in such a way that the parsing logic can understand different formats as input. However, the returned expression follows the rules defined in RadGridView, not for SQL.

If you need to construct an actual SQL query considering the applied filters to RadGridView, it is necessary to convert manually the expression according to the desired custom format. 

I hope this information helps. If you need any further assistance, please don't hesitate to contact me. 

Regards,
Nadya | Tech Support Engineer
Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.

Giovanni
Top achievements
Rank 1
Iron
Iron
Iron
commented on 27 Nov 2023, 07:38 AM

Thank you very much.
0
Nadya | Tech Support Engineer
Telerik team
answered on 20 Nov 2023, 11:24 AM

Hello, Giovanni,

According to the provided information it seems that you use CompositeDataFilterForm which uses RadDataFilter control. When you are having a string column, the filter expresions that are about to shown are relevant for string values. The "Is in list" option filters the rows by checking if the enered text is in the list. For example, if I type "King" in the text box, the grid would be filtered and show only the rows that contain this string in Last Name column:

However, if you want to remove the "Is in list" options from available filters you can use the following code snippet:

 private void RadGridView1_CreateCompositeFilterDialog(object sender, GridViewCreateCompositeFilterDialogEventArgs e)
 {
     CompositeDataFilterForm filterDialog = e.Dialog as CompositeDataFilterForm;
     filterDialog.DataFilter.EditorInitialized += DataFilter_EditorInitialized;
 }

 private void DataFilter_EditorInitialized(object sender, TreeNodeEditorInitializedEventArgs e)
 {
     TreeViewDropDownListEditor ddl = e.Editor as TreeViewDropDownListEditor;
     if (ddl != null)
     {
         BaseDropDownListEditorElement element = ddl.EditorElement as BaseDropDownListEditorElement;
         //remove "Is in List" filter option
         element.Items.RemoveAt(5);
     }
 }

I hope this helps. Should you have any other questions, do not hesitate to contact me.

Regards,
Nadya | Tech Support Engineer
Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.

0
Giovanni
Top achievements
Rank 1
Iron
Iron
Iron
answered on 20 Nov 2023, 02:02 PM | edited on 20 Nov 2023, 04:29 PM

Thank you!

It is not clear to me the meaning of that kind of filter...it seems to me the same as "equal to"...

Anyway thank you for the code to hide the filter.

 

If you can help me, I have a further question: is there a way to custom generate the expression?

I've noticed that for the date columns to I have a problem, because the radDataFilter.Expression generated is:

[myDate] >= #11/20/2023 14:55:07# 

I would like to have only the date without time, is it possible?
And  how can manage this expression to generate the SQL expression, cause the # is not accepted.

 

Tags
DataFilter GridView
Asked by
Giovanni
Top achievements
Rank 1
Iron
Iron
Iron
Answers by
Nadya | Tech Support Engineer
Telerik team
Giovanni
Top achievements
Rank 1
Iron
Iron
Iron
Share this question
or