Hi,
I’m testing kendo grid and trying to get it to read from asp.net WebMethod in a webform. I’ve tried many options in the code but nothing works. How can I return the correct json format for the grid to use?
[WebMethod]
[ScriptMethod(ResponseFormat = ResponseFormat.Json)]
public static string GetSomthing() {
// [{"ProductID":1,"ProductName":"Test Product"}]
}
I have the following script in the aspx page:
<script src="http://cdn.kendostatic.com/2013.3.1324/js/jquery.min.js"></script>
<link href="http://cdn.kendostatic.com/2013.3.1324/styles/kendo.common.min.css" rel="stylesheet" />
<link href="http://cdn.kendostatic.com/2013.3.1324/styles/kendo.default.min.css" rel="stylesheet" />
<script src="http://cdn.kendostatic.com/2013.3.1324/js/kendo.web.min.js"></script>
<div id="example" class="k-content">
<div id="grid"> </div>
<script>
$(document).ready(function () {
$("#grid").kendoGrid({
dataSource: {
transport: {
read: {
url: "KendoTest.aspx/GetSomthing",
dataType: "json",
type: "POST",
data: {}
}
},
schema: {
data: "d",
model: {
id: "ProductID",
fields: {
ProductID: { editable: true, type: "number" },
ProductName: { editable: true, type: "string" }
}
}
}
},
height: 250,
columns: [{
field: "ProductID"
}, {
field: "ProductName"
}]
});
});
</script>
</div>
Thanks.
I’m testing kendo grid and trying to get it to read from asp.net WebMethod in a webform. I’ve tried many options in the code but nothing works. How can I return the correct json format for the grid to use?
[WebMethod]
[ScriptMethod(ResponseFormat = ResponseFormat.Json)]
public static string GetSomthing() {
// [{"ProductID":1,"ProductName":"Test Product"}]
}
I have the following script in the aspx page:
<script src="http://cdn.kendostatic.com/2013.3.1324/js/jquery.min.js"></script>
<link href="http://cdn.kendostatic.com/2013.3.1324/styles/kendo.common.min.css" rel="stylesheet" />
<link href="http://cdn.kendostatic.com/2013.3.1324/styles/kendo.default.min.css" rel="stylesheet" />
<script src="http://cdn.kendostatic.com/2013.3.1324/js/kendo.web.min.js"></script>
<div id="example" class="k-content">
<div id="grid"> </div>
<script>
$(document).ready(function () {
$("#grid").kendoGrid({
dataSource: {
transport: {
read: {
url: "KendoTest.aspx/GetSomthing",
dataType: "json",
type: "POST",
data: {}
}
},
schema: {
data: "d",
model: {
id: "ProductID",
fields: {
ProductID: { editable: true, type: "number" },
ProductName: { editable: true, type: "string" }
}
}
}
},
height: 250,
columns: [{
field: "ProductID"
}, {
field: "ProductName"
}]
});
});
</script>
</div>
Thanks.