Hi,
We are trying to bind the JSON data to grid using "Read" transport datasource. but somehow the grid does not show any record. The JSON data is valid and returned by ASP.NET Web API. If the JSON data is copied to ".JSON" file and provided to datasource, it works.
One of the strange part noticed, when the result is binding internally (guess), the grid throws an error. The error is "ParserError". Below is the code snippet. Please let me know any work around.
If the dataSource type is changed to "JSON", the error message is "No Transport".
Regards,
Maulik
We are trying to bind the JSON data to grid using "Read" transport datasource. but somehow the grid does not show any record. The JSON data is valid and returned by ASP.NET Web API. If the JSON data is copied to ".JSON" file and provided to datasource, it works.
One of the strange part noticed, when the result is binding internally (guess), the grid throws an error. The error is "ParserError". Below is the code snippet. Please let me know any work around.
If the dataSource type is changed to "JSON", the error message is "No Transport".
<!DOCTYPE html>
<
html
xmlns
=
"http://www.w3.org/1999/xhtml"
>
<
head
>
<
title
>Test Page</
title
>
<
script
src
=
"js/jquery-1.7.1.min.js"
type
=
"text/javascript"
></
script
>
<
script
src
=
"Scripts/kendo.all.min.js"
type
=
"text/javascript"
></
script
>
<
link
href
=
"styles/kendo.common.min.css"
rel
=
"stylesheet"
/>
<
link
href
=
"styles/kendo.default.min.css"
rel
=
"stylesheet"
/>
<
script
src
=
"js/json2.js"
></
script
>
</
head
>
<
body
>
<
div
id
=
"example"
class
=
"k-content"
>
<
div
id
=
"grid"
></
div
>
<
input
id
=
"btnView"
type
=
"button"
value
=
"view"
onclick
=
"JavaScript: rebind();"
/>
<
script
>
function rebind() {
var gridDS = $("#grid").data("kendoGrid").dataSource;
gridDS.read();
}
$(document).ready(function () {
$("#grid").kendoGrid({
dataSource: {
type: "odata",
transport: {
read:"http://XYZ/JSON/Data",
contentType: "application/json; charset=utf-8",
type: "GET",
dataType: "json"
},
success: function (e) {
alert("Error: " + e.error);
},
schema: {
data: "Result"
},
error: function (e) {
debugger;
alert("Error: " + e.errorThrown);
},
change: function (e) {
alert("Change");
},
requestStart: function (e) {
//alert("Request Start");
},
pageSize: 10,
serverPaging: true,
serverFiltering: true,
serverSorting: true
},
height: 250,
filterable: true,
sortable: true,
pageable: true
});
});
</
script
>
</
div
>
</
body
>
</
html
>
Regards,
Maulik