Jquery 根据特定的列值,启用或禁用jqgrid中复选框的选择
我有一个jqgrid,我想在其中选择代理状态列中具有值“Running”的行。对于其余状态,我应该无法选择该行 JQGrid代码Jquery 根据特定的列值,启用或禁用jqgrid中复选框的选择,jquery,jqgrid,jqgrid-formatter,Jquery,Jqgrid,Jqgrid Formatter,我有一个jqgrid,我想在其中选择代理状态列中具有值“Running”的行。对于其余状态,我应该无法选择该行 JQGrid代码 datatype: "json", contentType: 'application/json', ajaxGridOptions: { contentType: 'application/json; charset=utf-8' }, colNames: ['Id', 'Machine Name', 'IP Address', 'Disc
datatype: "json",
contentType: 'application/json',
ajaxGridOptions: { contentType: 'application/json; charset=utf-8' },
colNames: ['Id', 'Machine Name', 'IP Address', 'Discovered Date', 'Agent Install Status', 'Agent Installation Date', 'Agent Status', 'Agent Version', 'Last HeartBeat Recieved'],
colModel: [
{ name: 'id', hidden: false, width: 15, key: true },
{ name: 'machineName', width: 120 },
{ name: 'ipAddress', width: 60 },
{ name: 'discoveredDate', width: 110, formatter: 'date', formatoptions: { srcformat: 'y-m-d', newformat: 'l, F d, Y' } },
{ name: 'agentInstallStatus', width: 70 },
{ name: 'agentInstallationDate', width: 110, formatter: 'date', formatoptions: { srcformat: 'y-m-d', newformat: 'l, F d, Y' } },
{ name: 'agentStatusName', width: 90 , edittype:'select', editoptions:{value:"Running"} },
{ name: 'agentVersion', width:50},
{ name: 'lastHeartBeatRecieved', width: 110, formatter: 'date', formatoptions: { srcformat: 'y-m-d', newformat: 'l, F d, Y' } }
],
sortname: 'id',
sortorder: 'asc',
loadonce: true,
viewrecords: true,
gridview: true,
width: gwdth,
height: 650,
rowNum: 10,
rowList: [10, 20, 30],
mtype: 'GET',
multiselect: true,
multipleSearch: true,
pager: "#jqGridPager"
});
是否可能仅显示运行状态的复选框
我对这种环境完全陌生 我认为有两个主要选项可以实现您的要求:
- 使用
callback禁用基于rowattr
列内容的行。请参见为创建“agentStatusName”
- 在SelectRow回调之前使用
上使用(以及在SelectAll
),以防止根据
列的内容选择行“agentStatusName”
第一个选择是最简单和安全的。第二个更灵活。您可以允许编辑行(如果需要),但仍然可以阻止选择。谢谢您的回答。。这对我来说很有效,我只需要为您提供的第二个链接添加rowattr callback。是否可以仅禁用复选框列而不是整行?如果是,你能分享一个演示吗link@AbhishekPandey:1)GitHub support callback中免费jqGrid的当前代码,可用于从某些行(基于内容)中删除复选框。2) 如果您不想删除复选框,但只想禁用,可以在
cb
列中使用cellatr
(可以在onInitGrid
中设置回调)cellattr
可以设置相同的类,如rowattr
@AbhishekPandey:上述两种实现的缺点是:一种必须在选择Row之前添加,另一种必须在选择上添加以防止选择(如中)。因此,禁用行的方式是首选方式。好的,谢谢您的帮助和回复