繁体   English   中英

如何从Kendo网格获取检查的行?

[英]How to get checked rows from 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委托,我将像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
})

如果以后要遍历控制器中选中的行,则可以使用

postUrl = '@Url.Content("~/Billing/CustomerAccountManage/AccountsManagerTransferResponsiblityAction")';  
     paramValue = JSON.stringify(  
     {  
       'pEmpID1': gEmpID1  
       , 'pEmpID2': gEmpID2  
       , ManagerList: gridData // passing the grid value in controller as parameter  
     });  
     $.ajax({  
       url: postUrl,  
       type: 'POST',  
       dataType: 'json',  
       data: paramValue,  
       contentType: 'application/json; charset=utf-8',  
       success: function (result) {  
         console.log(result);  
       },  
       error: function (objAjaxRequest, strError) {  
         var respText = objAjaxRequest.responseText;  
         console.log(respText);  
       }  
     });  

你也可以看到这个

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM