The Microsoft ODATA JavaScript API on CodePlex has the option enableJsonPCallback = false and it allows it to work.
Funny how their samples on CodePlex use the Telerik ODATA services.
44 Answers, 1 is accepted
I'm afraid that currently DataSource expect data to be in valid JSONP format. Maybe you can use similar to this extension to enable the JSONP support of DataServices.
Regards,Rosen
the Telerik team

@Michael: Did you make a copy of kendo.data.odata.js and modify the read properties. That would allow you to adjust transports.odata.read with your own settings.
Rainer
Indeed, using JSONP is not a requirement but an options. However, in this case data returned from the service should be in a valid format. Sure if cross domain requests are not used, JSONP is not required.
Regards,Rosen
the Telerik team

I was able to get what I needed to work by using the Microsoft datajs API. For the Keno datasource I pass in data.results and the Kendo controls render just fine. For the grid the loading icon doesn't seem to work or the refresh method. Is there an example on how to pass and object into the transport object of the datasource? I'm thinking that might be required for the grid refresh either that or is doesn't work in the beta.
The application sample I have working is really nice. Out of box SharePoint 2010 related lists as the backend and Kendo for the interface.

Give it a try and the issue with the loading icon might go away as well. I haven't looked too deeply at the code but if you inspect a kendo.data.DataSource instance you'll find some private properties like _pending or _requestInProgress that are probably used by the UI widgets. As you are not using kendo.data.Datasource for retrieving the data those will most likely not updated correctly.
Rainer

By accident I was able to get the Kendo ODATA datasource to work without any modifications. The format is:
dataSource: {
type: "odata",
transport: {
read: {
url: "[url]",
dataType: "json"
}
}
}
Works great with SharePoint 2010. Of course the SharePoint client api would work just as well.
Another interesting item I found is that the Microsoft DataJS script works with ODATA cross domain without JSONP.

I am trying to use a SharePoint list in a grid using one of the examples but no entries appear. Can you guys spot something obvious?
<div id="example" class="k-content">
<div id="grid"></div>
<script>
var dateRegExp = /^\/Date\((.*?)\)\/$/;
function toDate(value) {
var date = dateRegExp.exec(value);
return new Date(parseInt(date[1]));
}
$(document).ready(function() {
$("#grid").kendoGrid({
dataSource: {
type: "odata",
transport: {
read: {
url: "http://testserver/sites/testsite/_vti_bin/listdata.svc/TestList",
dataType: "json"
}
},
schema: {
model: {
fields:
{
Title: { type: "string" },
Created: { type: "date" }
}
}
},
pageSize: 10,
serverPaging: true,
serverFiltering: true,
serverSorting: true
},
height: 250,
filterable: true,
sortable: true,
pageable: true,
columns:
[
"Title",
{
field: "Created",
template: '#= kendo.toString(toDate(Created), "MM/dd/yyyy")#'
}
]
});
});
</script>
</div>


.../_vti_bin/listdata.svc/Testlist?$format=json&$inlinecount=allpages&$callback=callback&$top=10
When using individual js files kendo.data.odata.js correctly extends kendo.data to ommit those two params.
This seems to be broken when using kendo.all.js. Wish KendoUI would support modules in AMD format, that would help avoiding issues like that :).
<script src="../../source/js/kendo.core.js"></script>
<script src="../../source/js/kendo.model.js"></script>
<script src="../../source/js/kendo.data.js"></script>
<script src="../../source/js/kendo.data.odata.js"></script>
<script src="../../source/js/kendo.grid.js"></script>
<script src="../../source/js/kendo.list.js"></script>
<script src="../../source/js/kendo.pager.js"></script>
<script src="../../source/js/kendo.sortable.js"></script>
<script src="../../source/js/kendo.filtermenu.js"></script>
<script src="../../source/js/kendo.popup.js"></script>
<script src="../../source/js/kendo.selectable.js"></script>
<script src="../../source/js/kendo.dropdownlist.js"></script>
<script src="../../source/js/kendo.numerictextbox.js"></script>
<script src="../../source/js/kendo.calendar.js"></script>
<script src="../../source/js/kendo.datepicker.js"></script>
Rainer

I am not using kendo.all, I am using the individual files.
Would be nice to get a response from Michael how he implemented this?

You can use the data.js library to make it work:
http://datajs.codeplex.com/
I did make a sample, with beta 2, where the page I have it is hosted within SharePoint and accesses the SP object model directly but it has weird issues with the controls only partially populating and freezing.
I havn't tried the release version yet.

For a quick hack modify kendo.data.odata.js
parameterMap: function(options) {
var result = ["$format=json", "$inlinecount=allpages", "$callback=callback"],
to
parameterMap: function(options) {
var result = ["$inlinecount=allpages"],
Once you got it working use information earlier in that thread to create your own adapter.

I still cannot get this to work. Did your hack work for you?
Thanks,
David

Changing kendo.data.odata.js works and causes my WCF data service to return data.
However, I'm still not getting Kendo to process the data and display it in a grid. I'm using a standard task list in SP2010 as datasource and I've verified with Fiddler that I'm actually getting data back from the service. But Kendo is not processing the data and displaying it in the grid.
Below is my source.
Any comments on this?
Best regards,
Peter
<script>
$(document).ready(function () {
var sharableDataSource = new kendo.data.DataSource({
type: "odata",
transport: {
read: "http://sp2010/_vti_bin/listdata.svc/Tasks"
},
pageSize: 10,
serverFiltering: true,
serverPaging: true,
serverSorting: true
});
$("#grid").kendoGrid({
dataSource: sharableDataSource,
height: 250,
scrollable: true,
sortable: true,
pageable: true,
columns: ["Title", "StatusValue", "Description "]
});
});
</script>

If not you'd need to define the appropriate schema in your kendo.data.Datasource.
@David: Yes that works for me both with your testlist and on an OOTB tasks list.
<body>
<div id="example" class="k-content">
<div id="grid"></div>
<script>
var dateRegExp = /^\/Date\((.*?)\)\/$/;
function toDate(value) {
var date = dateRegExp.exec(value);
return new Date(parseInt(date[1]));
}
$(document).ready(function() {
$("#grid").kendoGrid({
dataSource: {
type: "odata",
transport: {
read: {
url: "http://2010dev/sites/kendoui/ODATA/_vti_bin/listdata.svc/Tasks",
dataType: "json"
}
},
schema: {
model: {
fields:
{
Title: { type: "string" },
Created: { type: "date" },
StatusValue: { type: "string" }
}
}
},
pageSize: 10,
serverPaging: true,
serverFiltering: true,
serverSorting: true
},
height: 250,
filterable: true,
sortable: true,
pageable: true,
columns:
[
"Title",
{
field: "Created",
template: '#= kendo.toString(toDate(Created), "MM/dd/yyyy")#'
},
"StatusValue"
]
});
});
</script>
</div>
</body>

Nope, doesn't work. Below is copy of my entire file. Only difference between yours and mine is header and URL to odata service.
It doesn't even call the odata feed to get data.
Getting this to work should be a no-brainer.
/peter
<!DOCTYPE html>
<html>
<head>
<title></title>
<script src="js/jquery.min.js" type="text/javascript"></script>
<script src="js/jquery.tmpl.min.js" type="text/javascript"></script>
<link href="styles/kendo.common.min.css" rel="stylesheet" type="text/css" />
<link href="styles/kendo.default.min.css" rel="stylesheet" type="text/css" />
<script src="js/kendo.core.min.js"></script>
<script src="js/kendo.model.min.js"></script>
<script src="js/kendo.data.min.js"></script>
<script src="js/kendo.data.odata.min.js" type="text/javascript"></script>
<script src="js/kendo.grid.min.js"></script>
<script src="js/kendo.list.min.js"></script>
<script src="js/kendo.pager.min.js"></script>
<script src="js/kendo.sortable.min.js"></script>
<script src="js/kendo.filtermenu.min.js"></script>
<script src="js/kendo.popup.min.js"></script>
<script src="js/kendo.selectable.min.js"></script>
<script src="js/kendo.dropdownlist.min.js"></script>
<script src="js/kendo.numerictextbox.min.js"></script>
<script src="js/kendo.calendar.min.js"></script>
<script src="js/kendo.datepicker.min.js"></script>
</head>
<body>
<div id="example" class="k-content">
<div id="grid"></div>
<script>
var dateRegExp = /^\/Date\((.*?)\)\/$/;
function toDate(value) {
var date = dateRegExp.exec(value);
return new Date(parseInt(date[1]));
}
$(document).ready(function () {
$("#grid").kendoGrid({
dataSource: {
type: "odata",
transport: {
read: {
url: "http://sp2010/_vti_bin/listdata.svc/Tasks",
dataType: "json"
}
},
schema: {
model: {
fields:
{
Title: { type: "string" },
Created: { type: "date" },
StatusValue: { type: "string" }
}
}
},
pageSize: 10,
serverPaging: true,
serverFiltering: true,
serverSorting: true
},
height: 250,
filterable: true,
sortable: true,
pageable: true,
columns:
[
"Title",
{
field: "Created",
template: '#= kendo.toString(toDate(Created), "MM/dd/yyyy")#'
},
"StatusValue"
]
});
});
</script>
</div>
</body>
</html>


For Sharepoint you need to update the schema section and tell the datasource how the odata feed returns data. This is the only addition you would need to make to Peter's example to get it to work. Note the bolded data: "d.results", addition. Hopefully this helps someone.
schema: {
data: "d.results",
model: {
fields:
{
Title: { type: "string" },
Created: { type: "date" },
StatusValue: { type: "string" }
}
}
};

Thnx for your quick reply.
Unfortunately it still doesn't work. Data is returned - but the grid isn't populated. I'm pulling my hair out right now.
Also, why is it required to document the model coming back from the odata source? This is not a requirement when using straight json from a file. Using odata with Kendo really feels second grade, when it should be point, grid or chart and you're cooking with gas.
Telerik, please jump onboard and solve this issue.
Best regards,
Peter
We are not sure what the problem may be in your case. Can you confirm that your service is returning JSON? Is there any way to reproduce your configuration at our side?
Greetings,Atanas Korchev
the Telerik team


I'm using a vanilla installation of SP2010 Enterprise with SP1 (with all updates and the ADO.NET update to fix oData). The datasource is the standard /_vti_bin/listdata.svc from any site.
After doing some investigation with Fiddler it turns out that the odata service in SharePoint will not return JSON with any of the standard (or previously mentioned changes to .odata.js). However the "standard" online odata feeds like:
http://services.odata.org/Northwind/Northwind.svc
http://odata.netflix.com/v2/Catalog/
Do return data as JSON when called through Kendo.
Usually it's possible to force odata to return JSON by adding contentType: "application/json" to the request header. But somehow this isn't happening when using Kendo.
Not really sure where to go from here.
Best regards,
Peter
Currently the Kendo DataSource will work only with OData services which can serve JSON responses. OData services which can only return XML must be configured as a XML datasources. Have in mind though that in this case the remote service should live in the same domain. There is a well known limitation of the XMLHTTPRequest to work only in same domains. JSONP indeed works cross domain but can only deliver JSON responses.
We currently don't have a SP2010 Enterprise with SP1 at our disposal. Is there any public test instance which we can test with?
Atanas Korchev
the Telerik team

Just an update to this thread re: JSON and sharepoint 2010. I have used the SPServices available at codeplex, and have added the GetJSONListData modification, this allows the XML to be transformed into JSON. My code now look something like this when populating the Kendo datasource.
var projData = $().SPServices.GetJSONListData({
listName: "Announcements", // don't forget - its list NAME, not an Url
columns: ["ID", "Title", "Created"],
debug: true
});
dataSource: {
data: projData,
schema: {
data: "rows",
model: {
fields:
{
Title: { type: "string" },
Created: { type: "date" }
}
}
},
pageSize: 10,
serverPaging: true,
serverFiltering: true,
serverSorting: true
},
height: 250,
filterable: true,
sortable: true,
pageable: true,
columns:
[
"Title",
{
field: "Created",
template: '#= kendo.toString(new Date(Date.parse(Created)), "dd MMM HH:mm")#'
}
]
});
I need help in getting the date to display correctly though. See attached modified SPServices file.

From the three options only listdata.svc is handled by the KendoUI ODATA implementation. It uses a mapping to ODATA terms like like $top, $skip, $inlinecount, etc (see http://www.odata.org/developers/protocols/uri-conventions for full list) to abstract the underlying data source and provide an interface to their widgets.
If you choose to use one of the other options it would be up to you to provide such an wrapper. This blog post should get you started http://www.kendoui.com/blogs/teamblog/posts/11-08-25/shields_up_web_service_abstraction_with_kendo_ui.aspx
Rainer

http://spservices.codeplex.com/wikipage?title=%24%28%29.SPServices.SPXmlToJson
As far as Sharepoint 2010 goes, if you're looking to use listdata.svc and have it be accessed anonymous, and use claims in an extended webpapp, you're going to run into issues. I could never get anonymous access to work for listdata.svc. Even though I could access the full list anonymously, whenever I tried hitting listdata.svc to pull any data back it wanted authentication.
The good thing about Sharepoint is there area ton of options for accessing the lists. The client-object model is fairly easy to use and you can get your output in an array relatively easy. You can also pull the contact via the server-side via a DataViewWebPart and then customize the XSLT so that it returns HTML data in just about any fashion you want. I can give examples of both of those if needed.

Any solutions?

In kendo.data.odata.js comment the lines
jsonp: "$callback" and
$format: "json"
Sharepoint code below (aspx page inside sharepoint, all js and css files are referenced from a document library)
js/css references and below code was placed inside <asp:Content ContentPlaceHolderId="PlaceHolderMain" runat="server">
<script id="NameTemplate" type="text/x-kendo-tmpl">
<span> ${ CreatedBy.LastName }, ${CreatedBy.FirstName} </span>
</script>
<div id="example" class="k-content">
<div id="grid"></div>
<script type="text/javascript">
$(document).ready(function() {
$("#grid").kendoGrid({
dataSource: {
type: "odata",
transport: {
read:
{
url: "http://sharepointsite/_vti_bin/ListData.svc/ListSample?$expand=CreatedBy",
contentType: "application/json; charset=utf-8" ,
type: "GET",
dataType: "json"
}
},
schema: {
model: {
fields: {
Title: { type: "string" },
CreatedBy:
{
FirstName: {type: "string" },
LastName: {type: "string" },
},
Id: { type: "number" }
}
}
},
pageSize: 10,
serverPaging: true,
serverFiltering: true,
serverSorting: true
},
height: 250,
filterable: true,
sortable: true,
pageable: true,
columns: [
{ field: "Title" },
{ field: "Id" },
{
title: "Created By",
template: kendo.template($("#NameTemplate").html())
} ]
});
});
</script>
</div>
The important change is
contentType: "application/json; charset=utf-8" ,
type: "GET",

Anybody have an example of a working file and the js you used to get it to work? The error I get is
The query parameter '$callback' begins with a system-reserved '$' character
I realize I could go this route... http://archive.msdn.microsoft.com/DataServicesJSONP but isn't that for custom services? Not sure how to apply that Sharepoint's default web services.
Anyway, anybody using a recent kendo version with Sharepoint 2010 and have it working?

The solution posted here works for me.
Note the commented sections in odata.js file
transports: {
odata: {
read: {
cache: true, // to prevent jQuery from adding cache buster
dataType: "jsonp"
//jsonpCallback: "callback", //required by OData
//jsonp: false
//jsonp: "$callback"
},
parameterMap: function(options, type) {
type = type || "read";
var params = {
//$format: "json",
$inlinecount: "allpages"
},
option,
dataType = (this.options || defaultDataType)[type].dataType;
I am not able to attach the file in this thread...

Got it working.

Could you share the modified odata file for the latest version of Kendo. I upgraded and it stopped working for me too and I am not able to figure out what I am missing.
Thanks

I was able to get the data from a SharePoint as you all have suggested. I'm using the kendo.all.js with the soem changes (removing $format=json and call back)
Now i am trying to create a new record row and update the back end list. But when i click on Add new record, it gives and javascript error saying "Cannot read property '__count' of undefined" when i inspect my results received (json result from SharePoint service) i dont see a __count property there. Am i missing something here?
Simply i want to create a new record and update it in SharePoint back end, and also want to do update on existing items.
Thanks in advance for your all help.

Note -- You need to make sure to reference each kendo js file singularly. Note Rainer's post above.
Here's the end of mine...
extend(true, kendo.data, {
schemas: {
odata: {
type: "json",
data: "d.results",
total: "d.__count"
}
},
transports: {
odata: {
read: {
cache: true, // to prevent jQuery from adding cache buster
dataType: "jsonp",
// jsonp: "$callback"
},
parameterMap: function(options, type) {
type = type || "read";
var params = {
// $format: "json",
$inlinecount: "allpages"
},
option,
dataType = (this.options || defaultDataType)[type].dataType;
options = options || {};
for (option in options) {
if (mappers[option]) {
mappers[option](params, options[option]);
} else {
params[option] = options[option];
}
}
return params;
}
}
}
});
I use a content editor web part with a content link to reference a separate file. Here's what I have in that file..... EXACTLY, only modifying the URL.
<
link
href
=
"/_layouts/assets/kendoui/styles/kendo.common.min.css"
rel
=
"stylesheet"
/>
<
link
href
=
"/_layouts/assets/kendoui/styles/kendo.default.min.css"
rel
=
"stylesheet"
/>
<
script
src
=
"/_layouts/assets/kendoui/source/js/jquery.js"
type
=
"text/javascript"
></
script
>
<
script
src
=
"/_layouts/assets/kendoui/source/js/jquery.tmpl.js"
type
=
"text/javascript"
></
script
>
<
script
src
=
"/_layouts/assets/kendoui/source/js/kendo.core.js"
></
script
>
<
script
src
=
"/_layouts/assets/kendoui/source/js/kendo.model.js"
></
script
>
<
script
src
=
"/_layouts/assets/kendoui/source/js/kendo.data.js"
></
script
>
<
script
src
=
"/_layouts/assets/kendoui/source/js/kendo.data.odata.js"
type
=
"text/javascript"
></
script
>
<
script
src
=
"/_layouts/assets/kendoui/source/js/kendo.grid.js"
></
script
>
<
script
src
=
"/_layouts/assets/kendoui/source/js/kendo.list.js"
></
script
>
<
script
src
=
"/_layouts/assets/kendoui/source/js/kendo.pager.js"
></
script
>
<
script
src
=
"/_layouts/assets/kendoui/source/js/kendo.sortable.js"
></
script
>
<
script
src
=
"/_layouts/assets/kendoui/source/js/kendo.filtermenu.js"
></
script
>
<
script
src
=
"/_layouts/assets/kendoui/source/js/kendo.popup.js"
></
script
>
<
script
src
=
"/_layouts/assets/kendoui/source/js/kendo.selectable.js"
></
script
>
<
script
src
=
"/_layouts/assets/kendoui/source/js/kendo.dropdownlist.js"
></
script
>
<
script
src
=
"/_layouts/assets/kendoui/source/js/kendo.numerictextbox.js"
></
script
>
<
script
src
=
"/_layouts/assets/kendoui/source/js/kendo.calendar.js"
></
script
>
<
script
src
=
"/_layouts/assets/kendoui/source/js/kendo.datepicker.js"
></
script
>
<
div
id
=
"grid"
></
div
>
<
script
>
$(document).ready(function () {
var ds = new kendo.data.DataSource({
type: "odata",
transport: {
read: {
dataType: "json"
},
},
schema: {
data: "d.results",
model: {
fields:
{
Title: { type: "string" },
Id: { type: "number" },
}
}
},
});
$("#grid").kendoGrid({
dataSource: ds,
columns:
[
{ field: "Title", title: "Title"},
{ field: "Id", title: "Id"},
],
});
});
</
script
>
The above looks at a document library called "Documents" and returns the Title and Id. You could point to a regular list instead. I highly recommend starting off by just pulling back Title, or Title and Id, just to make sure everything works. I also always start off using a grid, that way I know the datasource and JSON is correct.



transports: {
odataCors: {
update: {
type:
"POST"
,
dataType:
"json"
,
data:
""
,
contentType:
"application/json"
,
beforeSend:
function
(xhr, s) { s.data = JSON.stringify($.parseQueryString(s.data)); }
},
}
}
You then configure your data source:
var
ds =
new
kendo.data.DataSource({
type:
"odataCors"
,
transport: {
read: baseUri+
"d/Contacts"
,
update: { url: baseUri+
"d/Contacts"
}
}
});
Full odataCors source included (bear in mind that it is just a really quick example, not full fledged working code...).

I've tried with LightSwitch OData and it didn't work with kendo UI as Json format conversion required.
Anyone found the solution, how to integrate LS OData services to Kendo UI.
I've tried all ways 1) kendo.data.odataCors.js and it didn't worked.
Please suggest the working sample for calling LS Odata.
Regards
Rama

If any one has working Kendo code to get the sharepoint list as a datasource .. please help me..

The problem comes when specifying the binding path for a field in the model when using schema.data: "/feed/entry".
I used "fields: { title: "content/m:properties/d:Title/text() ..." but this generates a error in the Kendo dataSource definition complaining of a missing ")". Of course, normal X-Path definitions work just fine. Just not when there's a namespace prefix as in "m" and "d" above. My guess us the colon (":") throws the kendo.expr() function generator a knuckle ball and it swings and misses.
If you don't have to use namespace prefixes the dataSource is happy as in id: "id/text()" which renders as the Url to the specific list item.
Can Telerik help us out on how to specify namespace prefixes for Xml return data?

- The 3rd quarter release appears to have new syntax, is there an update to the odata js hack?
- Has anyone been able to make this work with lightswitch?
I can't the lightswitch data to appear in the grid using the latest bits from lightswitch and kendoui..
Thanks for your help,
jb

. ie. can we get some help in how to specify embedded namespace ie data: "/books/myns:book" where myns is a namespace urn


SP2013 works well with latest kendo build out of the box with no customizations.
For 2010, instead of modifying the Kendo api, I have found the following solution works with latest kendo build.
Add the following jquery code to your js.
$(document).ajaxSend(function (e, jqxhr, settings) {
if (settings.url.toLowerCase().indexOf("/_vti_bin/listdata.svc".toLowerCase()) >= 0) {
jqxhr.setRequestHeader("Accept", "application/json");
}
});
For a more detailed explanation, refer to this link https://community.dynamics.com/crm/b/zhongchenzhoustipstricksandportaldevelopment/archive/2012/05/20/how-to-use-kendo-ui-datasource-kendo-ui-grid-with-dynamics-crm-2011-rest-endpoint.aspx
It is relevant for MS Dynamics but works for SharePoint as well.