JqGrid添加数据行中添加按钮

colNames: ['NewRequestId', 'Applicant', 'Applicant Department','Edit', 'Delete'], 
colModel: [
{ name: 'NewRequestId', index: 'NewRequestId', hidden: true, sortable: false, align: "center", "1px" },
{ name: 'ApplicatUserName', index: 'ApplicatUserName', sortable: false, align: "center", "120px" },
{ name: 'ApplicatDepartment', index: 'ApplicatDepartment', sortable: false, align: "center", "140px" },
{ name: 'Edit', index: 'Edit', sortable: false, align: "center", "100px" },

{ name: 'Delete', index: 'Delete', sortable: false, align: "center", "100px" }

],

在gridComplete事件中添加:

gridComplete: function () {
var ids = jQuery("#RequestList").jqGrid('getDataIDs');
for (var i = 0; i < ids.length; i++) {
var id = ids[i];
var DeleteBtn = "<a href='#' style='color:#f60' onclick='OpenAllocationDialog()' >Abolish</a>";
var editBtn = "<a href='#' style='color:#f60' onclick='OpenAllocationDialog()' >Edit</a>";
jQuery("#RequestList").jqGrid('setRowData', ids[i], { Edit: editBtn, Delete: DeleteBtn });
}


},

原文地址:https://www.cnblogs.com/hexinxiaoyao/p/2674678.html