簡體   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