Reputation: 3061
I have a jqgrid, where I want to select the rows which has value "Running" in Agent Status Column. For rest of the status, I should not be able to select the row.
The JQGrid code
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"
});
Is it possible that I show checkBoxes only for the Running Status?
I am completely new to this environment.
Upvotes: 3
Views: 5615
Reputation: 221997
I see two main options to implement your requiremens:
rowattr
callback to disable the rows based on the content of "agentStatusName"
column. See the demo created for the answer.beforeSelectRow
callback (and onSelectAll
too) to prevent selection of rows based on the content of "agentStatusName"
column.The first choice is the mostly simple and safe. The second one is more flexible. One can allow to edit rows (if it is required), but still prevent selection.
Upvotes: 2