【发布时间】:2014-11-27 14:12:18
【问题描述】:
我在 JQGrid 中显示了数据,并获得了一个 Actions 列,其中有用于删除和编辑操作的图标。在我检索以显示在网格中的数据中,我有一个布尔值,我想仅在布尔值为真时显示图标。怎么可能?
这是我的 JQGrid 显示的一段代码:
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"/>'
});
编辑:这里是一个示例 JSON,2 行:
[{"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}]
应根据 JSON 中的“手动”字段禁用操作。
编辑:按照我从 Oleg 的回答中理解的内容,我将其添加到我的网格中:
rowattr: function (rd) {
if (rd.manual === false) { // verify that the testing is correct in your case
return {"class": "not-editable-row"};
}
},
但它仍然无法正常工作。
【问题讨论】: