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

Unable to Expand Datasource for Kendo Grid

1 Answer 33 Views
Data Source
This is a migrated thread and some comments may be shown as answers.
Anil
Top achievements
Rank 1
Anil asked on 03 Jun 2014, 08:52 PM
hello,

I'm trying to get some odata information into Kendo Grid.
I'm  not able to bring the CoverageName  information from the expanded client industry data.
The following code was used.

<div id="grid" style="width:100%"></div>
<script>
$(document).ready(function () {
$("#grid").kendoGrid({
dataSource: {
type: "odata",
transport: {
read: {
url: "http://localhost/_vti_bin/ListData.svc/Conflicts?$select=ClientName,ClientIndustry&$expand=ClientIndustry",
contentType: "application/json; charset=utf-8",
type: "GET",
dataType: "json",
}
},

schema: {
model: {
fields: {
ClientName: { type: "string" },
ClientIndustry: { type: "string" },
}
},
},


},

height: 600,
scrollable: false,
pageable: {
pageSize: 10,
pageSizes: true,
},

columns: [
{
title: "Client Name",
field: "ClientName"
}, {
title: "Client Industry",
field: "ClientIndustry.CoverageName"

}
]
})

});
</script>

</div>

Here is the feed that is used.

<feed xml:base="http://localhost/_vti_bin/ListData.svc/">
<title type="text">Conflicts</title>
<id>
http://localhost/_vti_bin/ListData.svc/Conflicts
</id>
<updated>2014-06-03T20:38:33Z</updated>
<link rel="self" title="Conflicts" href= "Conflicts" />
<entry m:etag="W/"2"">
<id>
http://localhost/_vti_bin/ListData.svc/Conflicts(1)
</id>
<title type="text"/>
<updated>2014-05-27T14:53:44-04:00</updated>
<author>
<name/>
</author>
<link rel="edit" title="ConflictsItem" href= "Conflicts(1)" />
<link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/ClientIndustry" type="application/atom+xml;type=feed" title="ClientIndustry" href= "Conflicts(1)/ClientIndustry" >
<m:inline>
<feed>
<title type="text">ClientIndustry</title>
<id>
http://localhost/_vti_bin/ListData.svc/Conflicts(1)/ClientIndustry
</id>
<updated>2014-06-03T20:38:33Z</updated>
<link rel="self" title="ClientIndustry" href= "Conflicts(1)/ClientIndustry" />
<entry m:etag="W/"1"">
<id>
http://localhost/_vti_bin/ListData.svc/Coverage(2)
</id>
<title type="text"/>
<updated>2014-05-08T10:12:10-04:00</updated>
<author>
<name/>
</author>
<link rel="edit" title="CoverageItem" href= "Coverage(2)" />
<link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/CreatedBy" type="application/atom+xml;type=entry" title="CreatedBy" href= "Coverage(2)/CreatedBy" />
<link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/ModifiedBy" type="application/atom+xml;type=entry" title="ModifiedBy" href= "Coverage(2)/ModifiedBy" />
<link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/Attachments" type="application/atom+xml;type=feed" title="Attachments" href= "Coverage(2)/Attachments" />
<category term="Microsoft.SharePoint.DataService.CoverageItem" scheme="http://schemas.microsoft.com/ado/2007/08/dataservices/scheme"/>
<content type="application/xml">
<m:properties>
<d:Id m:type="Edm.Int32">2</d:Id>
<d:ContentTypeID>
0x01003E9402529E024F93800379376BCEED6C0036470C1A4E7E52468FE68C989A4CDAA2
</d:ContentTypeID>
<d:ContentType>ListFieldsContentType</d:ContentType>
<d:Modified m:type="Edm.DateTime">2014-05-08T10:12:10</d:Modified>
<d:Created m:type="Edm.DateTime">2014-05-08T10:12:10</d:Created>
<d:CreatedById m:type="Edm.Int32">2</d:CreatedById>
<d:ModifiedById m:type="Edm.Int32">2</d:ModifiedById>
<d:Owshiddenversion m:type="Edm.Int32">1</d:Owshiddenversion>
<d:Version>1.0</d:Version>
<d:Path>/localhost/Lists/Coverage</d:Path>
<d:CoverageName>Alternative Capital Finance</d:CoverageName>
<d:IsActive m:type="Edm.Boolean">true</d:IsActive>
</m:properties>
</content>
</entry>
</feed>
</m:inline>
</link>
<category term="Microsoft.SharePoint.DataService.ConflictsItem" scheme="http://schemas.microsoft.com/ado/2007/08/dataservices/scheme"/>
<content type="application/xml">
<m:properties>
<d:ClientName>Abc Corp</d:ClientName>
</m:properties>
</content>
</entry>
<entry m:etag="W/"6"">
<id>
http://localhost/_vti_bin/ListData.svc/Conflicts(2)
</id>
<title type="text"/>
<updated>2014-05-27T12:54:00-04:00</updated>
<author>
<name/>
</author>
<link rel="edit" title="ConflictsItem" href= "Conflicts(2)" />
<link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/ClientIndustry" type="application/atom+xml;type=feed" title="ClientIndustry" href= "Conflicts(2)/ClientIndustry" >
<m:inline>
<feed>
<title type="text">ClientIndustry</title>
<id>
http://localhost/_vti_bin/ListData.svc/Conflicts(2)/ClientIndustry
</id>
<updated>2014-06-03T20:38:33Z</updated>
<link rel="self" title="ClientIndustry" href= "Conflicts(2)/ClientIndustry" />
<entry m:etag="W/"1"">
<id>
http://localhost/_vti_bin/ListData.svc/Coverage(3)
</id>
<title type="text"/>
<updated>2014-05-08T10:12:10-04:00</updated>
<author>
<name/>
</author>
<link rel="edit" title="CoverageItem" href= "Coverage(3)" />
<link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/CreatedBy" type="application/atom+xml;type=entry" title="CreatedBy" href= "Coverage(3)/CreatedBy" />
<link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/ModifiedBy" type="application/atom+xml;type=entry" title="ModifiedBy" href= "Coverage(3)/ModifiedBy" />
<link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/Attachments" type="application/atom+xml;type=feed" title="Attachments" href= "Coverage(3)/Attachments" />
<category term="Microsoft.SharePoint.DataService.CoverageItem" scheme="http://schemas.microsoft.com/ado/2007/08/dataservices/scheme"/>
<content type="application/xml">
<m:properties>
<d:Id m:type="Edm.Int32">3</d:Id>
<d:ContentTypeID>
0x01003E9402529E024F93800379376BCEED6C0036470C1A4E7E52468FE68C989A4CDAA2
</d:ContentTypeID>
<d:ContentType>ListFieldsContentType</d:ContentType>
<d:Modified m:type="Edm.DateTime">2014-05-08T10:12:10</d:Modified>
<d:Created m:type="Edm.DateTime">2014-05-08T10:12:10</d:Created>
<d:CreatedById m:type="Edm.Int32">2</d:CreatedById>
<d:ModifiedById m:type="Edm.Int32">2</d:ModifiedById>
<d:Owshiddenversion m:type="Edm.Int32">1</d:Owshiddenversion>
<d:Version>1.0</d:Version>
<d:Path>/localhost/Lists/Coverage</d:Path>
<d:CoverageName>Consumer & Retail</d:CoverageName>
<d:IsActive m:type="Edm.Boolean">true</d:IsActive>
</m:properties>
</content>
</entry>
<entry m:etag="W/"1"">
<id>
http://localhost/_vti_bin/ListData.svc/Coverage(8)
</id>
<title type="text"/>
<updated>2014-05-08T10:12:10-04:00</updated>
<author>
<name/>
</author>
<link rel="edit" title="CoverageItem" href= "Coverage(8)" />
<link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/CreatedBy" type="application/atom+xml;type=entry" title="CreatedBy" href= "Coverage(8)/CreatedBy" />
<link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/ModifiedBy" type="application/atom+xml;type=entry" title="ModifiedBy" href= "Coverage(8)/ModifiedBy" />
<link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/Attachments" type="application/atom+xml;type=feed" title="Attachments" href= "Coverage(8)/Attachments" />
<category term="Microsoft.SharePoint.DataService.CoverageItem" scheme="http://schemas.microsoft.com/ado/2007/08/dataservices/scheme"/>
<content type="application/xml">
<m:properties>
<d:Id m:type="Edm.Int32">8</d:Id>
<d:ContentTypeID>
0x01003E9402529E024F93800379376BCEED6C0036470C1A4E7E52468FE68C989A4CDAA2
</d:ContentTypeID>
<d:ContentType>ListFieldsContentType</d:ContentType>
<d:Modified m:type="Edm.DateTime">2014-05-08T10:12:10</d:Modified>
<d:Created m:type="Edm.DateTime">2014-05-08T10:12:10</d:Created>
<d:CreatedById m:type="Edm.Int32">2</d:CreatedById>
<d:ModifiedById m:type="Edm.Int32">2</d:ModifiedById>
<d:Owshiddenversion m:type="Edm.Int32">1</d:Owshiddenversion>
<d:Version>1.0</d:Version>
<d:Path>/localhost/Lists/Coverage</d:Path>
<d:CoverageName>Governments</d:CoverageName>
<d:IsActive m:type="Edm.Boolean">true</d:IsActive>
</m:properties>
</content>
</entry>
</feed>
</m:inline>
</link>
<category term="Microsoft.SharePoint.DataService.ConflictsItem" scheme="http://schemas.microsoft.com/ado/2007/08/dataservices/scheme"/>
<content type="application/xml">
<m:properties>
<d:ClientName>Test IBM</d:ClientName>
</m:properties>
</content>
</entry>
<entry m:etag="W/"3"">
<id>
http://localhost/_vti_bin/ListData.svc/Conflicts(3)
</id>
<title type="text"/>
<updated>2014-05-29T12:39:00-04:00</updated>
<author>
<name/>
</author>
<link rel="edit" title="ConflictsItem" href= "Conflicts(3)" />
<link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/ClientIndustry" type="application/atom+xml;type=feed" title="ClientIndustry" href= "Conflicts(3)/ClientIndustry" >
<m:inline>
<feed>
<title type="text">ClientIndustry</title>
<id>
http://localhost/_vti_bin/ListData.svc/Conflicts(3)/ClientIndustry
</id>
<updated>2014-06-03T20:38:33Z</updated>
<link rel="self" title="ClientIndustry" href= "Conflicts(3)/ClientIndustry" />
<entry m:etag="W/"1"">
<id>
http://localhost/_vti_bin/ListData.svc/Coverage(4)
</id>
<title type="text"/>
<updated>2014-05-08T10:12:10-04:00</updated>
<author>
<name/>
</author>
<link rel="edit" title="CoverageItem" href= "Coverage(4)" />
<link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/CreatedBy" type="application/atom+xml;type=entry" title="CreatedBy" href= "Coverage(4)/CreatedBy" />
<link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/ModifiedBy" type="application/atom+xml;type=entry" title="ModifiedBy" href= "Coverage(4)/ModifiedBy" />
<link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/Attachments" type="application/atom+xml;type=feed" title="Attachments" href= "Coverage(4)/Attachments" />
<category term="Microsoft.SharePoint.DataService.CoverageItem" scheme="http://schemas.microsoft.com/ado/2007/08/dataservices/scheme"/>
<content type="application/xml">
<m:properties>
<d:Id m:type="Edm.Int32">4</d:Id>
<d:ContentTypeID>
0x01003E9402529E024F93800379376BCEED6C0036470C1A4E7E52468FE68C989A4CDAA2
</d:ContentTypeID>
<d:ContentType>ListFieldsContentType</d:ContentType>
<d:Modified m:type="Edm.DateTime">2014-05-08T10:12:10</d:Modified>
<d:Created m:type="Edm.DateTime">2014-05-08T10:12:10</d:Created>
<d:CreatedById m:type="Edm.Int32">2</d:CreatedById>
<d:ModifiedById m:type="Edm.Int32">2</d:ModifiedById>
<d:Owshiddenversion m:type="Edm.Int32">1</d:Owshiddenversion>
<d:Version>1.0</d:Version>
<d:Path>/localhost/Lists/Coverage</d:Path>
<d:CoverageName>Corporate Finance</d:CoverageName>
<d:IsActive m:type="Edm.Boolean">true</d:IsActive>
</m:properties>
</content>
</entry>
<entry m:etag="W/"1"">
<id>
http://localhost/_vti_bin/ListData.svc/Coverage(11)
</id>
<title type="text"/>
<updated>2014-05-08T10:12:10-04:00</updated>
<author>
<name/>
</author>
<link rel="edit" title="CoverageItem" href= "Coverage(11)" />
<link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/CreatedBy" type="application/atom+xml;type=entry" title="CreatedBy" href= "Coverage(11)/CreatedBy" />
<link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/ModifiedBy" type="application/atom+xml;type=entry" title="ModifiedBy" href= "Coverage(11)/ModifiedBy" />
<link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/Attachments" type="application/atom+xml;type=feed" title="Attachments" href= "Coverage(11)/Attachments" />
<category term="Microsoft.SharePoint.DataService.CoverageItem" scheme="http://schemas.microsoft.com/ado/2007/08/dataservices/scheme"/>
<content type="application/xml">
<m:properties>
<d:Id m:type="Edm.Int32">11</d:Id>
<d:ContentTypeID>
0x01003E9402529E024F93800379376BCEED6C0036470C1A4E7E52468FE68C989A4CDAA2
</d:ContentTypeID>
<d:ContentType>ListFieldsContentType</d:ContentType>
<d:Modified m:type="Edm.DateTime">2014-05-08T10:12:10</d:Modified>
<d:Created m:type="Edm.DateTime">2014-05-08T10:12:10</d:Created>
<d:CreatedById m:type="Edm.Int32">2</d:CreatedById>
<d:ModifiedById m:type="Edm.Int32">2</d:ModifiedById>
<d:Owshiddenversion m:type="Edm.Int32">1</d:Owshiddenversion>
<d:Version>1.0</d:Version>
<d:Path>/localhost/Lists/Coverage</d:Path>
<d:CoverageName>Industrials - Airlines</d:CoverageName>
<d:IsActive m:type="Edm.Boolean">true</d:IsActive>
</m:properties>
</content>
</entry>
</feed>
</m:inline>
</link>
<category term="Microsoft.SharePoint.DataService.ConflictsItem" scheme="http://schemas.microsoft.com/ado/2007/08/dataservices/scheme"/>
<content type="application/xml">
<m:properties>
<d:ClientName>Test ABC inc</d:ClientName>
</m:properties>
</content>
</entry>
</feed>

1 Answer, 1 is accepted

Sort by
0
Daniel
Telerik team
answered on 05 Jun 2014, 12:59 PM
Hello Anil,

I posted my reply in the support ticket on the same topic. For convenience, I am pasting it below:

At least in the feed the item seems to be expanded. Could you provide the JSON response from the server for the grid dataSource request as well? A possible reason for the data not to be shown in this scenario is that for some of the records the "ClientIndustry" is null which will cause an error with the current setup. In this case you should use a template and access the "CoverageName" property only when the object is not null e.g.
{ field: "ClientIndustry.CoverageName", template: "#: ClientIndustry ? ClientIndustry.CoverageName : ''#"}


Regards,
Daniel
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
Tags
Data Source
Asked by
Anil
Top achievements
Rank 1
Answers by
Daniel
Telerik team
Share this question
or