使用jqgrid和editUrl,在编辑模式下,(当我点击编辑按钮时) 它显示不需要的标签,如“INPUT style =”WIDTH:98%“id = .....”
如何驾驭这个&仅显示文本框内的值。
我使用的代码如下。
jQuery("#myGrid").jqGrid({
pager: jQuery('#myGridPager'),
sortname: 'Name',
rowNum: 10,
rowList: [10, 20, 50],
sortorder: "asc",
height: "auto",
autowidth: true,
colNames: ['Id', 'Name', 'Dept', 'Status', 'ParentNodeName'],
colModel: [
{ name: 'Id', index: 'Id', hidden: true, key : true },
{ name: 'Name', index: 'Name', width: 200, editable: true, edittype: "text", editrules: { required: true} },
{ name: 'Dept', index: 'Dept', width: 90, editable: true, editrules: { required: true} },
{ name: 'Status', index: 'Status', width: 25, editable: true, edittype: "select", editoptions: { value: "A:Active;I:Inactive"} },
{ name: 'ParentNodeName',
index: 'ParentNodeName',
editable: true,
edittype: "select",
editoptions: { dataUrl: "/MyEntity/GetMyEntitys" }
},
],
datatype: 'json',
viewrecords: true,
mtype: 'GET',
jsonReader: {
root: "rows",
page: "page",
total: "total",
records: "records",
repeatitems: false,
userdata: "userdata"
},
url: "/MyEntity/GetMyEntitysData",
multiselect: false,
editurl: "/MyEntity/EditMyEntity?__SESSIONKEY=<%=Model.SessionKey %>",
caption: "Data Entry"
})
.navGrid('#myGridPager', { view: true, del: true, add: true, edit: true },
{ height: 150, reloadAfterSubmit: false, modal: true }, // default settings for edit
{ height: 150, reloadAfterSubmit: true, modal: true, url: "/MyEntity/AddMyEntity?__SESSIONKEY=<%=Model.SessionKey %>" }, // settings for add
{ height: "auto", reloadAfterSubmit: false, modal: true, url: "/MyEntity/DeleteMyEntity?__SESSIONKEY=<%=Model.SessionKey %>" }, // delete
{ closeOnEscape: true, multipleSearch: true, closeAfterSearch: true }, // search options
{} /* view parameters*/
);
答案 0 :(得分:0)
要在使用代码模式后解决此问题,请执行以下操作: 当显示编辑对话框时,我们正在更改(伪造)可编辑属性;并在关闭对话框时将其设置为true。这样,只能在编辑对话框中编辑值,而不能在网格中编辑。 但是这段代码也解决了不需要的标签问题。
.navGrid('#' + myGridPager, { view: false, del: true, add: true, edit: true },
{ //Edit options
height: 200,
reloadAfterSubmit: true,
modal: true,
viewPagerButtons: false,
closeAfterEdit: true,
closeOnEscape: true,
url: "MyEntity/EditMyEntity?__SESSIONKEY=<%=Model.SessionKey %>",
beforeInitData: function (formId) {
var cpr = bagrid.jqGrid('getColProp', 'Name');
cpr.editable = true;
},
onClose: function () {
var cpr = bagrid.jqGrid('getColProp', 'Name');
cpr.editable = false;
}
},
.....
可以更改列属性以进行编辑,添加或删除模式,如上所示。我们可以使用此代码模式隐藏或取消隐藏网格或对话框中的列。