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

Search as you type and non-string columns

2 Answers 438 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Maurice
Top achievements
Rank 1
Maurice asked on 14 Mar 2019, 12:44 AM

Some interesting behaviour can be observed when using the search-as-you-type function of the grid and non-string columns.

Is there a generic way to handle these so you can literally search any column using a "contains" approach?

I have bound an external textbox for the filter, but it gives the same result when using the built-in controls. Observations are:

  1. string columns filter fine
  2. numeric columns filter as per screenshots. note the actual value is 3493.29 which is only found for its integer value, at which point the grid removes its decimal value, or its entire value, not any substring of that value
  3. date columns do not filter unless the entire date is entered, and it is not highlighted in the grid per normal

Is there a standard approach that can be utilised for all column types as the benefit to this and me not rolling my own, is the built in template and styling of the highlighted results.

 

Thank you,

Maurice

2 Answers, 1 is accepted

Sort by
0
Yoan
Telerik team
answered on 18 Mar 2019, 04:06 PM
Hello Maurice,

Actually, the behavior you are observing is expected. Generally, when you are searching over RadGridView for dates/numbers you need to fill in the whole number or date as the operator used in such case is "IsEqualTo". On the other hand, a "Contains" operator is used for searching for string properties. For example, if you have the number 103 and 10322, but write only 103, then only the first result will be displayed.

That being said, I am afraid that there is no generic way of handling this scenario. However, there is a possible solution here - you can introduce new properties in your model. These properties can hold the string representation of your date/numeric columns. Then you can define columns which are bound to the new properties but are not visible in the grid (you can use Column's IsVisible property).

Please note that the search mechanism works for the visible columns by default. So, in order to search in the invisible ones, you need to set GridView's CanUserSearchInHiddenColumns property. More information about it can be found in this help article. The drawback of this approach is that the highlighting functionality will not be triggered for your real numeric columns.

Regards,
Yoan
Progress Telerik
Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
0
Maurice
Top achievements
Rank 1
answered on 21 Mar 2019, 05:09 AM

Thank you Yoan.

That is a little disappointing, I can understand column filtering being numeric but I expected the free text search to behave differently. I will have to roll my own logic for the free text search of any data in the grid.

Regards,
Maurice

Tags
GridView
Asked by
Maurice
Top achievements
Rank 1
Answers by
Yoan
Telerik team
Maurice
Top achievements
Rank 1
Share this question
or