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

Kendo grid filtering on field as object property

2 Answers 373 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Syam
Top achievements
Rank 1
Syam asked on 18 Mar 2014, 03:50 PM
Some of the columns in my grid are bound to properties of nullable objects. When there exists a nullable object, filtering stops working because the property's owner is null. Is this not supported OOTB? If so, can anyone suggest some alternate solutions for this? Are the only options to flatten my JSON or to modify the received JSON in requestEnd?

Below is a plnkr that demonstrates the issue. Btw, not sure why the live preview isn't working. Click the 'Launch preview in separate window' to view the code in action. To reproduce, 1. filter the 'foo value' column with any value. 2. you will see the grid display a timer. the console will also display an error.

https://plnkr.co/edit/wCrMZM5ieDHVpjLJpHhP?p=preview

2 Answers, 1 is accepted

Sort by
0
Alexander Popov
Telerik team
answered on 20 Mar 2014, 02:48 PM
Hi Syam,

I already replied to the ticket you opened, but I will copy the answer here in case anyone else has the same issue: 
I am afraid that this scenario is not supported and the possible workarounds are exactly the ones you want to avoid. Basically the DataSource is trying to access a property of an object that does not exists, so the only way to make this work is add both the object and the property beforehand.

Regards,
Alexander Popov
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
0
Syam
Top achievements
Rank 1
answered on 28 Mar 2014, 02:49 AM
We did end up choosing an alternate solution to work around this problem. For columns that are bound to a field of a an object which is nullable, we configured a custom filter function and a custom sorter which are null safe. Like such:

{
title: 'foo',
field: 'foo.bar',
filterable: { field: 'getNullSafeFooForFilter()' },
sortable : { compare: nullSafeFooComparator }
}
Tags
Grid
Asked by
Syam
Top achievements
Rank 1
Answers by
Alexander Popov
Telerik team
Syam
Top achievements
Rank 1
Share this question
or