Kendo ui 使用复选框获取剑道网格中列的值

Kendo ui 使用复选框获取剑道网格中列的值,kendo-ui,kendo-grid,Kendo Ui,Kendo Grid,我有一个带有复选框的网格 @(Html.Kendo().Grid<Re.Web.ReService>() .Name("ServiceList") .Columns(columns => { columns.Bound(p => p.P

我有一个带有复选框的网格

                        @(Html.Kendo().Grid<Re.Web.ReService>()
                    .Name("ServiceList")
                        .Columns(columns =>
                        {
                            columns.Bound(p => p.PKiServiceID)
                            .ClientTemplate("<input name=\"selectedIds\" type=\"checkbox\" value=\"#=PKiServiceID#\" class=\"chk\"/>")
                            .HeaderTemplate("<input type=\"checkbox\" class=\"selectAll\" />")
                            .Width(30);
                            columns.Bound(p => p.SServiceName).Width(200);
                            columns.Bound(p => p.MServicePrice).Width(80);
                            columns.Bound(p => p.BStatus).Width(70).ClientTemplate("#if(BStatus){# #='Y'# #} else {# #='N'# #}#");
                            columns.Bound(p => p.SDescription);
                        })
                    .Selectable()
                    .Pageable()
                    .DataSource(dataSource => dataSource
                        .Ajax()
                        .Model(model => model.Id(p => p.PKiServiceID))
                        .Read(read => read.Action("ServiceRead", "Home"))
                    )
                    )
我可以选中/取消选中网格中的所有行
现在我想,如果我点击全选复选框,我会得到MServicePrice列的所有值,这样我就可以计算出总值。我尝试使用
$(this)。最近('tr')
,但它在check all处理程序中不起作用

意味着网格中的所有项都将被检查,所以您问的是如何基本上获取所有项的值

您可以使用数据源并遍历view()集合

e、 g

    $(document).ready( function () {
    var grid = $("#ServiceList").data("kendoGrid");

    //handle the click of the header checkbox
    grid.table.on("change", ".selectAll", function () {
        var checkbox = $(this);
        if (checkbox.is(':checked')) {
            grid.table.find("tr")
                .find("td:first input")
                .attr("checked", checkbox.is(":checked"));

        }
        else {
            grid.table.find("tr")
                .find("td:first input")
                .attr("checked", checkbox.is(":checked"));
        }
    });
});
function checkAll(ele) {        
    var grid = $('#gridName').data().kendoGrid;
    var total = 0;
    $.each(grid.dataSource.view(), function () {           
        total += this.Salary;            
    });
    alert(total);        
}