Hi,
WCF Service returning JSON string for hierarchical grid. While binding to grid, I am getting following error. In examples I found two different services calling for Parent and Child. My requirement is one JSON string with hierarchical gird.
<div id="example" class="k-content">
<div id="grid">
</div>
<script type="text/javascript">
$(function () {
dataSource = new kendo.data.DataSource({
schema: {
model: {
id: "_grdData"
}
},
pageSize: 10,
transport: {
read: { url: "/Service.svc/GetData", datatype: "json", type: "GET" },
parameterMap: function (data, operation) {
if (operation != "read") {
return JSON.stringify({ Service : data })
}
}
}
}),
$("#grid").kendoGrid({
dataSource: dataSource,
pageable: true,
scrollable: {
virtual: false //false
},
detailInit: detailInit,
dataBound: function () {
this.expandRow(this.tbody.find("tr.k-master-row").first());
},
toolbar: ["create"],
editable: "popup",
columns: [
{ field: "name", title: "Name", width: "150px" }
]
});
});
function detailInit(e) {
console.log("Name: " + e.data.child[0].name );
console.log("Name1:" + e.data.child[0].name1 );
$("<div/>").appendTo(e.detailCell).kendoGrid({
dataSource: dataSource,
filter: { field: "id", operator: "eq", value: e.data.id},
columns: [
{ field: e.data.child[0].name, title: "Name", width: "150px" },
{ field: e.data.child[0].name1, title: "Name 1", width: "150px" }
]
});
}
</script>
</div>
JSon Data from service :
[{"name":"All","id":5369,"child":[{"name":"All","id":5369,"child":null,"name1":"sample name"}],"name1":null}]
WCF Service returning JSON string for hierarchical grid. While binding to grid, I am getting following error. In examples I found two different services calling for Parent and Child. My requirement is one JSON string with hierarchical gird.
Invalid
template:'<tr
data-uid="#=uid#"><td>${All}</td><td>${sample name}</td></tr>' Generated code:'var
o,e=kendo.htmlEncode;with(data){o='<tr
data-uid="'+(uid)+'"><td>'+(e(All))+'</td><td>'+(e(sample name))+'</td></tr>';}return o;'
<div id="example" class="k-content">
<div id="grid">
</div>
<script type="text/javascript">
$(function () {
dataSource = new kendo.data.DataSource({
schema: {
model: {
id: "_grdData"
}
},
pageSize: 10,
transport: {
read: { url: "/Service.svc/GetData", datatype: "json", type: "GET" },
parameterMap: function (data, operation) {
if (operation != "read") {
return JSON.stringify({ Service : data })
}
}
}
}),
$("#grid").kendoGrid({
dataSource: dataSource,
pageable: true,
scrollable: {
virtual: false //false
},
detailInit: detailInit,
dataBound: function () {
this.expandRow(this.tbody.find("tr.k-master-row").first());
},
toolbar: ["create"],
editable: "popup",
columns: [
{ field: "name", title: "Name", width: "150px" }
]
});
});
function detailInit(e) {
console.log("Name: " + e.data.child[0].name );
console.log("Name1:" + e.data.child[0].name1 );
$("<div/>").appendTo(e.detailCell).kendoGrid({
dataSource: dataSource,
filter: { field: "id", operator: "eq", value: e.data.id},
columns: [
{ field: e.data.child[0].name, title: "Name", width: "150px" },
{ field: e.data.child[0].name1, title: "Name 1", width: "150px" }
]
});
}
</script>
</div>
JSon Data from service :
[{"name":"All","id":5369,"child":[{"name":"All","id":5369,"child":null,"name1":"sample name"}],"name1":null}]