javascript - 如何从剑道网格中获取选中的行?

标签 javascript jquery html checkbox kendo-grid

我尝试在每一行中使用复选框,然后获取这些行的值(已检查)。此复选框列不代表数据源中的任何字段。这是我的网格:

 var SeparatedEmployeeList = $("#SeparatedEmployeeList").kendoGrid({
             dataSource: DataSourceSeparatedEmployeeList,
             pageable: true,
             editable: true,
             selectable: "row",
             navigatable: true,
             filterable: true,
             sortable: true,
             groupable: true,
             height: '200PX',

             scrollable: true,
             columns: [
               { field: "SLNO", title: "SL.", filterable: false, sortable: false, width: "30px" },
               { field: "EMP_CODE", title: "Code", filterable: false, width: "70px" },
               { field: "EMP_NAME", title: "Name", filterable: true, width: "100px" },
               { field: "DIVI_NAME", title: "Division", width: "70px" },
               { field: "EMP_DESIG_NAME", title: "Designation", width: "75px" },
               { field: "JOINING_DATE", title: "Join Date", width: "60px" },
               { field: "TRMN_TYPE", title: "Separation Type", width: "85px" },
               { field: "TRMN_EFCT_DATE", title: "Effect Date", width: "60px" },
               { field: "LAST_SAL_PROS_MON", title: "Last Salary Proc. Month", width: "110px" },
               { field: "TRMN_REM", title: "Remarks", width: "60px" },
               { field: "Date", title: "Date", width: "65px" },
               { field: "check_row", title: "Submit", width: 60, onClick: test, template: "<input class='check_row' OnCheckedChanged='test' type='checkbox' />" }
             ]
         });

我需要触发一段时间检查复选框以验证用户在复选框之前定义的日期字段中输入的数据,稍后我将需要遍历选中的行以使用它们的值。请帮忙。

最佳答案

我会将最后一项更改为:

{ title: "Submit", width: 60, template: "<input class='check_row nsa-checkbox' type='checkbox' />" }

现在,使用 jQuery 委托(delegate),我将像 NSA 一样捕获 DIV 网格下每个控件上的所有“更改”事件,并具有 css 类“nsa-checkbox”:

$('#SeparatedEmployeeList').on('change', '.nsa-checkbox', function(e){
    // "this" is your checkbox
    var myCheckbox = $(this);

    // To get the item, you must access the data-uid attribute in the row that wraps the checkbox.    
    var myDataItem = DataSourceSeparatedEmployeeList.getByUid(myCheckbox.closest('tr').attr('data-uid'));

    // Have fun
})

关于javascript - 如何从剑道网格中获取选中的行?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21427193/

相关文章:

javascript - 如何在浏览器解释后使用 curl 扫描页面

javascript - 检测提交类型,如果是通过回车键或按钮单击

javascript - 如果在模板返回之前删除元素,则 knockout 组件将失败

jquery - 用自定义 css 覆盖 jquery 主题

javascript - chrome,javascript 在运行之间不更新

javascript - 无法动态操作多边形的坐标

javascript - Vuetify 中 v-for 重复元素的工具提示

javascript - jquery 按钮样式在 html 表中不起作用

javascript - 当我使用 jQuery 单击“选择”按钮时如何选择所有复选框

javascript - ng-repeat - 一旦弹出,就无法推送