我正在尝试使用每行的复选框和&然后获取那些行的值,这些值被检查。此复选框列不表示数据源中的任何字段。这是我的网格:
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' />" }
]
});
我需要点击一下复选框以在复选框之前定义的日期字段中验证用户输入的数据,&amp;稍后我将需要遍历已检查的行以使用它们的值。请帮忙。
答案 0 :(得分:3)
我会将最后一项更改为:
{ 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
})
答案 1 :(得分:0)
如果您以后想要遍历控制器中的已检查行,则可以使用
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);
}
});
您还可以看到this