通过自定义删除按钮jqgrid删除行
remove row by custom delete button jqgrid
我想使用自定义删除按钮删除行。我正在使用下面的代码片段:
var cellValue;
var id;
$gvRoleDetails = jQuery("#gvRoleDetails");
$gvRoleDetails.jqGrid({
datatype: 'local',
colNames: ['Role', 'Module', 'Function', 'AppRoleID', 'AppID', 'AppModuleID', 'AppFncID', 'PermCreate', 'PermEdit', 'PermView', 'PermDelete', 'PermAuth', 'PermCancel','RoleOrgID','Remove'],
onSelectRow: function (id) {
var rowData = jQuery(this).getRowData(id);
cellValue = rowData['AppFncID'];
},
colModel: [
{ name: 'Role', index: 'Role', width: 200 },
{ name: 'Module', index: 'Module', width: 200 },
{ name: 'Function', index: 'Function', width: 200 },
{ name: 'AppRoleID', index: 'AppRoleID', hidden: true },
{ name: 'AppID', index: 'AppID', hidden: true },
{ name: 'AppModuleID', index: 'AppModuleID', hidden: true },
{ name: 'AppFncID', index: 'AppFncID', hidden: true, key: true },
{ name: 'PermCreate', index: 'PermCreate', hidden: true },
{ name: 'PermEdit', index: 'PermEdit', hidden: true },
{ name: 'PermView', index: 'PermView', hidden: true },
{ name: 'PermDelete', index: 'PermDelete', hidden: true },
{ name: 'PermAuth', index: 'PermAuth', hidden: true },
{ name: 'PermCancel', index: 'PermCancel', hidden: true },
{ name: 'RoleOrgID', index: 'RoleOrgID', hidden: true },
{
name: 'Remove', index: 'AppFncID', sortable: false,
formatter: function (rowId, cellval, colpos, rwdat, _act) {
var rowInterviewId = colpos.AppFncID.toString();
return '<input type="button" id="' + rowInterviewId + '" value="Remove" class="btn" onClick = "RemoveData(this)" />';
}
}
],
rowNum: 10,
gridview: true,
autoencode: true,
height: "auto",
pager: '#jQGridDemoPager',
sortname: "Role",
multiselect: false,
viewrecords: true,
sortorder: "desc",
});
RemoveData 函数用于传递选定行值以进行删除:
function RemoveData(rowData) {
alert(rowData);
}
如何使用相同的结构通过 函数 RemoveData(rowData) 删除行?
我已经通过 rowData.id 在 rowid 变量中分配后删除,然后它运行良好。
function RemoveData(rowData) {
var rowid = rowData.id;
var su = $('#gvRoleDetails').jqGrid('delRowData', rowid);
$('#gvRoleDetails').trigger('reloadGrid');
}
我想使用自定义删除按钮删除行。我正在使用下面的代码片段:
var cellValue;
var id;
$gvRoleDetails = jQuery("#gvRoleDetails");
$gvRoleDetails.jqGrid({
datatype: 'local',
colNames: ['Role', 'Module', 'Function', 'AppRoleID', 'AppID', 'AppModuleID', 'AppFncID', 'PermCreate', 'PermEdit', 'PermView', 'PermDelete', 'PermAuth', 'PermCancel','RoleOrgID','Remove'],
onSelectRow: function (id) {
var rowData = jQuery(this).getRowData(id);
cellValue = rowData['AppFncID'];
},
colModel: [
{ name: 'Role', index: 'Role', width: 200 },
{ name: 'Module', index: 'Module', width: 200 },
{ name: 'Function', index: 'Function', width: 200 },
{ name: 'AppRoleID', index: 'AppRoleID', hidden: true },
{ name: 'AppID', index: 'AppID', hidden: true },
{ name: 'AppModuleID', index: 'AppModuleID', hidden: true },
{ name: 'AppFncID', index: 'AppFncID', hidden: true, key: true },
{ name: 'PermCreate', index: 'PermCreate', hidden: true },
{ name: 'PermEdit', index: 'PermEdit', hidden: true },
{ name: 'PermView', index: 'PermView', hidden: true },
{ name: 'PermDelete', index: 'PermDelete', hidden: true },
{ name: 'PermAuth', index: 'PermAuth', hidden: true },
{ name: 'PermCancel', index: 'PermCancel', hidden: true },
{ name: 'RoleOrgID', index: 'RoleOrgID', hidden: true },
{
name: 'Remove', index: 'AppFncID', sortable: false,
formatter: function (rowId, cellval, colpos, rwdat, _act) {
var rowInterviewId = colpos.AppFncID.toString();
return '<input type="button" id="' + rowInterviewId + '" value="Remove" class="btn" onClick = "RemoveData(this)" />';
}
}
],
rowNum: 10,
gridview: true,
autoencode: true,
height: "auto",
pager: '#jQGridDemoPager',
sortname: "Role",
multiselect: false,
viewrecords: true,
sortorder: "desc",
});
RemoveData 函数用于传递选定行值以进行删除:
function RemoveData(rowData) {
alert(rowData);
}
如何使用相同的结构通过 函数 RemoveData(rowData) 删除行?
我已经通过 rowData.id 在 rowid 变量中分配后删除,然后它运行良好。
function RemoveData(rowData) {
var rowid = rowData.id;
var su = $('#gvRoleDetails').jqGrid('delRowData', rowid);
$('#gvRoleDetails').trigger('reloadGrid');
}