如何使用网格刷新读取和更新剑道网格脚注模板值 [英] How to read and update the kendo grid footer template value with grid refresh
本文介绍了如何使用网格刷新读取和更新剑道网格脚注模板值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我遇到了与以下SO问题here中解释的问题类似的问题。
问题只解决了一半,如果页脚模板包含任何特殊模板定义,则不会显示如何更新该模板。
剑道网格FooterTemplate定义如下:
<% Html.Kendo().Grid<_3ECProject.Models.TransactionHistoryModel>()
.Name("creditnoteinfogrid")
.Columns(columns =>
{
columns.Bound(e => e.Amount).Format("{0:#,###.00}")
.ClientFooterTemplate("<div style='float: right'>#: kendo.toString(sum, '\#,\#\#\#.00') #</div>")
.FooterHtmlAttributes(new {id = "total-amount" });
}
.Events(events => events.Save("onGridCellSave"))
.DataSource(dataSource => dataSource.Ajax().Batch(true).ServerOperation(false)
.Aggregates(aggregates =>{
aggregates.Add(p => p.Amount).Sum();
})
)
%>
如何使用定义的customFooterTemplate()更新页脚模板。
使用KENDO-MVC-2020.3.915
推荐答案
我发现的一种方法是将页脚模板DOM元素替换为新的innerHTML,同时保持原始ClientFooterTemplate()不变。
function onGridCellSave(e) {
e.model.Amount = e.values.Amount;
var grid = $('#grid').data('kendoGrid');
var griddata = grid.dataSource.data();
var totalAmount = 0;
griddata.forEach(function (item, index) {
totalAmount = totalAmount + item.Amount;
});
console.log(totalAmount);
//This is the way I update the footer template cell by using the id property and set it with the same HTML set in the .ClientFooterTemplate()
document.getElementById("total-amount").innerHTML = "<div style='float: right'>" + kendo.toString(totalAmount, '#,###.00') + "</div>";
}
这篇关于如何使用网格刷新读取和更新剑道网格脚注模板值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文