I have data displayed in a JQGrid, and I get an Actions column, where I have icons for Delete and Edit actions. In the data I retrieve to display in the grid, I have a boolean, and I would like to display the icons only when the boolean is true. How could it be done?
Here the piece of code of my JQGrid display:
jQuery("#datagrid").jqGrid({
stateOptions: getStateOptions("creation-site"),
url: listUrl,
datatype: "json",
loadError: viewError,
colNames: ['', 'Nom', 'N de dépôt Geopost', 'IATA', 'Groupe ID', 'Site de rattachement', 'Poste comptable', 'Centre cout', 'Description'],
colModel: [
{name: 'myac', width: 80, fixed: true, sortable: false, resize: false, formatter: 'actions', formatoptions: {keys: true, editbutton: true, }},
{name: 'nom', index: 'nom', editable: true, edittype: "text", sortable: true},
{name: 'geopostDepotNumber', index: 'geopostDepotNumber', editable: true, edittype: "text", sortable: true},
{name: 'iata', index: 'iata', editable: true, edittype: "text", sortable: true},
{name: 'groupeId', index: 'groupeId', editable: true, edittype: "text", sortable: true},
{name: 'siteRattachement', index: 'siteRattachement', editable: true, edittype: "text", sortable: true},
{name: 'posteComptable', index: 'posteComptable', editable: true, edittype: "text", sortable: true},
{name: 'centreCout', index: 'centreCout', editable: true, edittype: "text", sortable: true},
{name: 'description', index: 'description', editable: true, edittype: "text", sortable: true}
],
rowList: [10, 20, 50, 100, 500, 1000, 5000],
pager: '#navGrid',
sortname: 'title',
sortorder: "asc",
viewrecords: true,
loadonce: true,
gridview: true,
ignoreCase: true,
height: 'auto',
editurl: 'clientArray',
caption: '<spring:message code="creationsite.title"/>'
});
Edit: Here a sample JSON, for 2 lines:
[{"id":1,"centreCout":"211177","geopostDepotNumber":"0401","iata":"MLV","posteComptable":"77999","referentielId":5,"siteRattachement":" ","nom":"Ceci est un nom","networkRefId":1,"networkRefName":"FR-CHR","description":"MARNE-LA-VALLEE","groupeId":"CHRF","manual":false},
{"id":2,"centreCout":"211174","geopostDepotNumber":"0402","iata":"FTV","posteComptable":"75998","referentielId":5,"siteRattachement":" ","nom":null,"networkRefId":1,"networkRefName":"FR-CHR","description":"ALFORTVILLE","groupeId":"CHRF","manual":false}]
The actions should be disabled depending on the "manual" field in the JSON.
Edit: Following what I understood from Oleg's answer, I added that to my grid:
rowattr: function (rd) {
if (rd.manual === false) { // verify that the testing is correct in your case
return {"class": "not-editable-row"};
}
},
but it's still not working.