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

Grid Column Filter for number type

3 Answers 669 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Anna
Top achievements
Rank 1
Anna asked on 03 Jun 2016, 06:48 PM

Hi,

I have problem to get filter on number type column working. Plunk: http://plnkr.co/edit/sBaDyB9OZtAJ9BKjQzwK?p=preview, The data structure as follow

Sample data: 

[{
    account: "AC",
    portfolio: "B",
    spendLine: [210, 220, 230, 240, 250]
  },
  ...
]

Since the data structure has array within array, I have trouble defining schema model. The column filter for the number type is always using string filter instead of number. How can I solve this problem?

3 Answers, 1 is accepted

Sort by
0
Boyan Dimitrov
Telerik team
answered on 07 Jun 2016, 11:58 AM

Hello Ama,

The Kendo UI DataSource is designed to operate with flat data which is why there is no specified type for 'object' or 'array'.Since such types are not officially supported there is no built-in filtering menus for such cases.

However the Filter Array Columns Using MultiSelect how-to shows how to enable filtering on a Grid column which is bound to an array field by using the Kendo UI Multiselect widget.

Regards,
Boyan Dimitrov
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
0
Anna
Top achievements
Rank 1
answered on 07 Jun 2016, 06:58 PM

That's a shame. Is there not a way to do number filtering in this case at all? Like I know we can customize the UI, is there opportunity to customize the operators?

Best,

Ama

0
Boyan Dimitrov
Telerik team
answered on 09 Jun 2016, 12:08 PM

Hello Ama,

As I mentioned the Kendo UI DataSource is designed to work with flat data. Since there is no option to define a type of  'object' or 'array' there is no built-in filter mechanism for such data types. 

There is a built-in number filtering, but it expects the cell to contain a single number value, not an array. The data structure should look like this in order to use the built-in number filtering: 

[{
    account: "AC",
    portfolio: "B",
    spendLine: 210
  },
  ...
]


Regarding the operator - the logic for the operator should be defined as separate function. For testing purposes in the provided how-to there is only one operator. It checks whether any of the values selected by the Kendo UI MultiSelect matches one of the numbers in the cell. 

Since such data type is not supported by the Kendo UI DataSource there is no built-in filter operators for working with an array of numbers. Such operators should be implemented by the developer in the same way as the one used in the example. 

In order to have more than one operator you can define Kendo UI DropDownList list and pass the selected operator to the Kendo Ui DataSource filter method.  

Regards,
Boyan Dimitrov
Telerik
 
Get started with Kendo UI in days. Online training courses help you quickly implement components into your apps.
 
Tags
Grid
Asked by
Anna
Top achievements
Rank 1
Answers by
Boyan Dimitrov
Telerik team
Anna
Top achievements
Rank 1
Share this question
or