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

Problem in Complex Binding Propertied to Grid

6 Answers 39 Views
Grid
This is a migrated thread and some comments may be shown as answers.
ahmed
Top achievements
Rank 1
ahmed asked on 05 Mar 2015, 06:37 AM
I bind to list of columns, some of them are complex like "ProfileDetails" property.
If we bind to a complex column like “ProfileDetails.FullAddress” while “ProfileDetails” object is null in received data  
we get an exception on JavaScript code and no data appear. 

can any one tell me how to fix it 

6 Answers, 1 is accepted

Sort by
0
ahmed
Top achievements
Rank 1
answered on 05 Mar 2015, 08:40 AM
Here is My Code Demo To Explain my problem : 
 var list= [{
        "EmployeID": "1",
        "ProfileDetails":
            {
                "id": 1,
                "FullAddress": "4 u st.,uk"
            },
 "isAdmin": false}];
  var tempSource = new kendo.data.DataSource({
        data: list,});
$("#grid").kendoGrid({
        dataSource: tempSource,
        columns: [{field:"EmployeID",title:"ID"},{field:"ProfileDetails.FullAddress",title:"Address"}],});
0
ahmed
Top achievements
Rank 1
answered on 05 Mar 2015, 08:42 AM
Here is My Code Demo To Explain my problem : 
 var list= [{
        "EmployeID": "1",
        "ProfileDetails":
            {
                "id": 1,
                "FullAddress": "4 u st.,uk"
            },
 "isAdmin": false},{
        "EmployeID": "2",
        "ProfileDetails":null,
 "isAdmin": true}];
  var tempSource = new kendo.data.DataSource({
        data: list,});
$("#grid").kendoGrid({
        dataSource: tempSource,
        columns: [{field:"EmployeID",title:"ID"},{field:"ProfileDetails.FullAddress",title:"Address"}],});
0
Petur Subev
Telerik team
answered on 07 Mar 2015, 07:52 AM
Hello Ahmend,

You can fix this by defining a safe template because the built-in one that is generated looks like this:

template: "#= complex.foo #"

And what you can use is:

template: "#= complex && complex.foo #"


Kind Regards,
Petur Subev
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
0
ahmed
Top achievements
Rank 1
answered on 08 Mar 2015, 08:26 AM
This fix my problem thank you
0
Jacques
Top achievements
Rank 2
answered on 08 Jun 2015, 02:39 PM

Using a template breaks filtering. You end up with the "".toLowerCase is not a function exception.

Kendo version: 2015.1.408

 

0
Boyan Dimitrov
Telerik team
answered on 10 Jun 2015, 01:25 PM

Hello Jacques,

Basically sorting / filtering / grouping of columns that are bound to a complex property from the model is not supported out-of-the-box as the Grid didn't have the information about which of the nested fields should be used for these operations.

If the field configuration is set as 

{field:"ProfileDetails.FullAddress",title:"Address"}

the filtering will work on the FullAdress value. 

Regards,
Boyan Dimitrov
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
Tags
Grid
Asked by
ahmed
Top achievements
Rank 1
Answers by
ahmed
Top achievements
Rank 1
Petur Subev
Telerik team
Jacques
Top achievements
Rank 2
Boyan Dimitrov
Telerik team
Share this question
or