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

Filtering and Search as you type

4 Answers 565 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Inger Marie
Top achievements
Rank 1
Inger Marie asked on 09 Feb 2017, 10:02 AM

I have a few columns in my RadGridView, which I would like to filter - but not to allow Search as You Type.

Is there  any way to do this?

 

In addition: I have boolean values, which I show as "Yes" and "No" in the grid - but in the filters, they are shown as "True" and "False". It there any way to change this to let the filter sow "Yes" and "No", too?

Best regards

Inger Marie

4 Answers, 1 is accepted

Sort by
0
Accepted
Stefan Nenchev
Telerik team
answered on 13 Feb 2017, 02:09 PM
Hello Inger Marie,

Currently, the RadGridView supports only full disable/enable of the Search Panel functionality. You can control it by setting the CanUserSearch property to True/False:

<telerik:RadGridView ItemsSource="{Binding Orders}"    
                         CanUserSearch="False"
                         Name="orderItemsDataGrid" Margin="5"
                         AutoGenerateColumns="False"
                         ColumnWidth="*"/>
Disabling the Search functionality for specific columns only is not supported at this point. However, there is a feature request for such behavior  - GridView: Add an option to exclude a column from "search as you type". I suggest you vote for it in order to increase its priority.

As for your second requirement, the default filtering control takes the raw values of the items. With this in mind, you can add an additional string property that returns Yes/No according to the boolean property and the column to it. Please check the attached sample for reference.

Have a great week.

Regards,
Stefan Nenchev
Telerik by Progress
Want to extend the target reach of your WPF applications, leveraging iOS, Android, and UWP? Try UI for Xamarin, a suite of polished and feature-rich components for the Xamarin framework, which you to write beautiful native mobile apps using a single shared C# codebase.
0
Inger Marie
Top achievements
Rank 1
answered on 21 Feb 2017, 09:46 AM

1) Apparently the Search Field uses the datamemberbinding in the search. So if I dont bind with datamemberbinding but uses celltemplate, grouppath, sortpath (not the exact names) etc, then I can avoid searching in the fields.

However, that does not seem right, so I upvoted the feature request.

2) I was hoping to be able to convert the filtering text - perhaps a FilterPath could be added in the future? - like it is possible to convert for instance the grouping text. Having another property in my ViewModel for displaying purposes is not my preferred way of doing things.

 

But thanks for the reply

0
Stefan Nenchev
Telerik team
answered on 22 Feb 2017, 10:55 AM
Hi Inger Marie,

Indeed, using a CellTemplate is a viable workaround.

As for the second issue,  the GridViewDataColumn exposes a FilterMemberPath property where you can point another property of the business object over which to apply the filtering as in the SortMemberPath and GroupMemberPath. However, I might have misled you in my previous reply. Adding a Converter to the DataMemberBinding would be respected by the filtering control:

public class BooleanToYesNoConverter : IValueConverter
   {
       public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
       {
           var boolValue = value is bool && (bool)value;
 
           return boolValue ? "Yes" : "No";
       }
 
       public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
       {
           return value != null && value.ToString() == "Yes";
       }
   }
. . .
<telerik:GridViewDataColumn DataMemberBinding="{Binding IsChampion, Converter={StaticResource TrueFalseConverter}}"/> 



Regards,
Stefan Nenchev
Telerik by Progress
Want to extend the target reach of your WPF applications, leveraging iOS, Android, and UWP? Try UI for Xamarin, a suite of polished and feature-rich components for the Xamarin framework, which you to write beautiful native mobile apps using a single shared C# codebase.
0
Inger Marie
Top achievements
Rank 1
answered on 22 Feb 2017, 11:07 AM

Thanks for clearing that up. I knew that too (now that you mention it), but I didn't think of it either :-)

Tags
GridView
Asked by
Inger Marie
Top achievements
Rank 1
Answers by
Stefan Nenchev
Telerik team
Inger Marie
Top achievements
Rank 1
Share this question
or