Disable inline and cell editing and only allow form editing in jqgrid
I have a grid which maintains mappings of meta data of some entity (e.g. a document). In such a case, we just have add or edit. Editing is to be done just to inactivate record
Since this is the case, we have no point using cell or inline editing. Form editing option will be the best
However, these forms show only those columns which have "editable: true"
So, how does one disable editing in the grid and enable it only for the form?
onSelectRow does not fire at all. Am I missing something??? I am using jqgrid 3.8
This is what I have tried:
var metaGrid = jQuery("#" + nodeMetaDataGrid);
metaGrid.jqGrid({
pager: jQuery("#" + nodeMetaDataGridPager),
emptyrecords: "No records to view",
sortname: 'Id',
rowNum: 30,
rowList: [50, 100, 'ALL'],
sortorder: "asc",
height: "auto",
autowidth: true,
colNames: ['Id', 'Meta Data Type', 'Meta Data Value', 'Status', 'Date Added', 'Date Removed'],
colModel: [
{ name: 'Id', index: 'Id', hidden: true, key: true },
{ name: 'MetaType', index: 'MetaType', width: 30, editable: false, edittype: "select", editoptions: { dataUrl: "My/GetList"} },
{ name: 'MetaValue', index: 'MetaValue', width: 30, editable: false, editrules: { required: true} },
{ name: 'Status', index: 'Status', width: 10, editable: false, edittype: "select", editoptions: { value: "A:Active;I:Inactive"} },
{ name: 'DateAdded', index: 'DateAdded', width: 20, editable: false },
{ name: 'DateRemoved', index: 'DateRemoved', width: 20, editable: false }
],
datatype: 'json',
viewrecords: true,
mtype: 'GET',
jsonReader: {
root: "rows",
page: "page",
total: "total",
records: "records",
repeatitems: false,
userdata: "userdata"
},
url: getUrl,
multiselect: false,
//editurl: "someurl"
caption: "Available Meta Data",
onSelectRow: function (id) {
alert("Before Iff statement");
if (id && id !== lastSel) {
alert("hi, selected");
jQuery(this).restoreRow(lastSel);
var cm = metaGrid.jqGrid('getColProp', 'MetaType');
cm.editable = false;
//grid.jqGrid('addRow', id, true, null, null, 'someURL');
//cm.editable = true;
lastSel = id;
}
}
})
.navGrid("#" + nodeMetaDataGridPager, { view: false, del: false, add: true, edit: true开发者_JAVA技巧, search: false },
{
//Edit mode
height: 150,
reloadAfterSubmit: true,
modal: true,
closeOnEscape: true,
url: "someURL"
},
{ //Add mode
height: "auto",
reloadAfterSubmit: false,
modal: true,
closeOnEscape: true,
url: "someURL",
recreateForm: true,
//trying to use this because onSelectRow does not fire
beforeShowForm: function (form) {
var cm = metaGrid.jqGrid('getColProp', 'MetaType');
cm.editable = true;
}
},
{
//Delete mode
},
{
//View mode
}
);
Thanks, Apploader
maybe you can just delete this statement:
onSelectRow: function (id) {
alert("Before Iff statement");
if (id && id !== lastSel) {
alert("hi, selected");
jQuery(this).restoreRow(lastSel);
var cm = metaGrid.jqGrid('getColProp', 'MetaType');
cm.editable = false;
//grid.jqGrid('addRow', id, true, null, null, 'someURL');
//cm.editable = true;
lastSel = id;
}
and add "cellEdit:false"
As kayla indicated, remove your onSelectRow block and use cellEdit... http://www.trirand.com/jqgridwiki/doku.php?id=wiki:cell_editing
精彩评论