The below code where I getting the list of data from List c# method and all the data is properly binding with all the columns property. But the problem is when I am passing a hrtotal and it is not setting dataBond property.
The below code is JsonResult List() method where I am passing totalhr through json.
<div id="totalHours">
</div>
<script>
var griddataSource = new kendo.data.DataSource({
transport: {
read: {
url: '@Url.Action("List", "GLID")',
dataType: "json",
success: function (result) {
var totalHours = result.totalhr;
}
},
schema: {
data: "data",
total: "total",
}
});
griddataSource.read();
$("#grid").kendoGrid({
dataSource: griddataSource,
toolbar: ["excel"],
dataBound: function(e) {
resizeGrid(e);
var totalHours = e.totalhr; // ****** I want to update the value of totalHour
$("#totalHours").text("Total new Hours: " + totalHours);
},
columns: [
]
});
</script>
The below code is JsonResult List() method where I am passing totalhr through json.
var totalHours = list.Sum(item => item.Hours);
return Json(new { total = total, totalhr = totalHours, data = data }, JsonRequestBehavior.AllowGet);
Hi,
The dataBound event handler will not provide information about the entire server response. I would suggest utilizing the dataSource requestEnd event. Below is an example:
dataSource: { requestEnd: function (result) { var totalHours = result.response.totalhr; $("#totalHours").text("Total new Hours: " + totalHours); }, transport: { read: { url: '@Url.Action("Orders_Read", "Grid")', dataType: "json" }, }, ....... },
Regards,
Neli