Checkbox 如何在剑道UI网格中获取复选框的值?

Checkbox 如何在剑道UI网格中获取复选框的值?,checkbox,kendo-grid,Checkbox,Kendo Grid,所以我已经搜索了很多答案,但似乎找不到关于这个的任何具体信息。。。这就是 我有一个标准的剑道UI网格-我已经设置了一个列,如下所示: { title: "Sharing Enabled?", field: "permissions_users_apps_user_sharing", attributes: { style: "text-align: center; font-size: 14px;" }, filterable: true,

所以我已经搜索了很多答案,但似乎找不到关于这个的任何具体信息。。。这就是

我有一个标准的剑道UI网格-我已经设置了一个列,如下所示:

{   title: "Sharing Enabled?", 
    field: "permissions_users_apps_user_sharing", 
    attributes: {
        style: "text-align: center; font-size: 14px;"
    },
    filterable: true,
    headerAttributes: {
        style: "font-weight: bold; font-size: 14px; width: 40px;"
    },
    template: function(dataItem) {
        if ( dataItem.permissions_users_apps_user_sharing == 0 ) {
            return "<input type='checkbox' name='permissions_users_apps_status' id='permissions_users_apps_status' value='1' />"
        } else if ( dataItem.permissions_users_apps_user_sharing == 1 ) {
            return "<input type='checkbox' name='permissions_users_apps_status' id='permissions_users_apps_status' value='1' checked />"
        }
    }
},
{title:“已启用共享?”,
字段:“权限\用户\应用程序\用户\共享”,
属性:{
样式:“文本对齐:居中;字体大小:14px;”
},
可过滤:正确,
校长致辞:{
样式:“字体大小:粗体;字体大小:14px;宽度:40px;”
},
模板:函数(数据项){
if(dataItem.permissions\u users\u apps\u user\u sharing==0){
返回“”
}else if(dataItem.permissions\u users\u apps\u user\u sharing==1){
返回“”
}
}
},
我试图做的是在单击已定义的命令按钮时获取此复选框的值(以查看是否已更改)。行是可选择的。。因此,我可以获取行的ID。但我似乎无法收集复选框的值

有人有什么建议吗


提前感谢。

当复选框状态更改时,您可以在数据绑定事件中获取复选框的实例。 看看下面的代码是否对您有帮助

 ....
 columns: [
 {
  { field: "select", template: '<input id="${BindedColumn}" onclick="GrabValue(this)" type="checkbox"/>', width: "35px", title: "Select" },
 }
 ....
 selectable: "multiple, row",
 dataBound: function () {
            var grid = this;
            //handle checkbox change
            grid.table.find("tr").find("td:nth-child(1) input")
            .change(function (e) {
                var checkbox = $(this);
                //Write code to get checkbox properties for all checkboxes in grid
                var selected = grid.table.find("tr").find("td:nth-child(1) input:checked").closest("tr");

                //Write code to get selected checkbox properties
                ......
                //Code below to clear grid selection
                grid.clearSelection();
                //Code below to select a grid row based on checkbox selection 
                if (selected.length) {
                    grid.select(selected);
                }
            })
        }
        .....
        function GrabValue(e)
        {
         //Alert the checkbox value
         alert(e.value);
         //get the grid instance
         var grid = $(e).closest(".k-grid").data("kendoGrid");
         //get the selected row data
         var dataItem = grid.dataSource.view()[grid.select().closest("tr").index()];
         }
。。。。
栏目:[
{
{字段:“选择”,模板:“”,宽度:“35px”,标题:“选择”},
}
....
可选:“多行,行”,
数据绑定:函数(){
var grid=此;
//处理复选框更改
grid.table.find(“tr”).find(“td:n子(1)输入”)
.更改(功能(e){
var复选框=$(此);
//编写代码以获取网格中所有复选框的复选框属性
所选变量=grid.table.find(“tr”).find(“td:n子(1)输入:选中”).closest(“tr”);
//编写代码以获取选中的复选框属性
......
//下面的代码用于清除网格选择
grid.clearSelection();
//下面的代码根据复选框选择网格行
如果(选定。长度){
grid.select(选中);
}
})
}
.....
函数值(e)
{
//警告复选框值
警觉(e.value);
//获取网格实例
var grid=$(e).最近(“.k-grid”).数据(“kendoGrid”);
//获取所选行数据
var dataItem=grid.dataSource.view();
}

使用此方法,您将获得选中的复选框值

          $("#MultiPayment").click(function () {
                var idsToSend = [];
                var grid = $("#Invoice-grid").data("kendoGrid")
                var ds = grid.dataSource.view();
                for (var i = 0; i < ds.length; i++) {
                    var row = grid.table.find("tr[data-uid='" + ds[i].uid + "']");
                    var checkbox = $(row).find(".checkboxGroups");
                    if (checkbox.is(":checked")) {
                        idsToSend.push(ds[i].Id);
                    }
                }
                alert(idsToSend);
                $.post("/whatever", { ids: idsToSend });
            });
$(“#多付款”)。单击(函数(){
var idsToSend=[];
var网格=$(“#发票网格”).data(“kendoGrid”)
var ds=grid.dataSource.view();
对于(变量i=0;i
更多细节