JqGrid添加数据行中添加按钮

本文详细介绍如何使用jqGrid插件动态生成操作栏,包括编辑和删除按钮,并通过gridComplete事件进行绑定。此方法适用于需要在表格中动态展示操作选项的场景。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

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

{ name: 'Delete', index: 'Delete', sortable: false, align: "center", width: "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/archive/2012/09/07/2674678.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值