我正在使用 JSP 和 Servlet(IDE:Eclipse,数据库:Oracle10)开发一个 Web 应用程序。
我正在使用 JQGRID 以表格格式显示数据。我还想要在 JQGRID 中添加、编辑、删除的功能。到目前为止,我已经完成了编辑、删除功能。
现在我想要添加功能,问题是当我点击默认Add
按钮时,它只显示DESCRIPTION
设置的字段,editable:true
而不显示其他两个不可编辑的字段。我没有将它们设置为可编辑,因为它们是主键,我不希望它们被编辑。
所以我的问题是有什么方法可以在用户单击添加后将不可编辑的列设置为可编辑。
以下是我的源代码:
jQuery("#list10_d2").jqGrid({
height: "100%",
url:'ProtocolJGridServChildStages?q=2&action=protStages',
datatype: "xml",
colNames:['Sr. No.','PROTOCOL_ID', 'STAGE_ID', 'DESCRIPTION'],
colModel:[{name:'srNo',index:'srNo', width:35,sortable:true},
{name:'PROTOCOL_ID',index:'PROTOCOL_ID', width:100,sortable:false},
{name:'STAGE_ID',index:'STAGE_ID', width:100,sortable:false},
{name:'DESCRIPTION',index:'DESCRIPTION', width:150,sortable:false,editable:true}
],
rowNum:5,
rowList:[2,4,10],
pager: '#pager10_d2',
sortname: 'PROTOCOL_ID',
viewrecords: true,
sortorder: "asc",
multiselect: true,
editurl: "ProtocolJGridServChildStages?action=protocolStageEdit",
caption:"CRM_PROT_STAGES",
onSelectRow: function(ids)
{
if(ids && ids!==lastsel)
{
var ret = jQuery("#list10_d2").jqGrid('getRowData',ids);
protID = ret.PROTOCOL_ID;
stageID = ret.STAGE_ID;
jQuery("#list10_d2").jqGrid('setGridParam',{editurl:'ProtocolJGridServChildStages?action=protocolStageEdit&protID='+protID+'&stageID='+stageID});
jQuery('#list10_d2').jqGrid('restoreRow',lastsel);
jQuery('#list10_d2').jqGrid('editRow',ids,true);
lastsel=ids;
}
}
}).navGrid('#pager10_d2',{add:true,edit:true,del:true},{width:400,height:200},{width:500,mtype:'POST', url: 'ProtocolJGridServChildStages', addData:{action:'protocolStageAdd',protID: function () {return protID;}, stageID: function(){return stageID;}}, closeOnSubmit: true},{mtype: 'POST',url: 'ProtocolJGridServChildStages',delData: {action: 'protocolStageDelete',protID: function () {return protID;}, stageID: function(){return stageID;}}});
jQuery("#ms1").click( function() {
var s;
s = jQuery("#list10_d2").jqGrid('getGridParam','selarrrow');
alert(s);
}).navGrid('#page',{edit:true,add:true,del:true});
提前致谢...
编辑:
.navGrid('#pager10_d2',{add:true,edit:true,del:true},{width:400,height:200},{width:500,mtype:'POST', url: 'ProtocolJGridServChildStages',beforeShowForm: function(){var cm = $('#list10_d2').jqGrid('getColProp',"PROTOCOL_ID"); cm.editable=true; cm = $('#list10_d2').jqGrid('getColProp',"STAGE_ID"); cm.editable=true; alert("before");}, addData:{action:'protocolStageAdd',protID: function () {return protID;}, stageID: function(){return stageID;}}, closeOnSubmit: true},{mtype: 'POST',url: 'ProtocolJGridServChildStages',delData: {action: 'protocolStageDelete',protID: function () {return protID;}, stageID: function(){return stageID;}}});
编辑
}).navGrid('#pager10_d2',{add:true,edit:true,del:true},
{closeOnEscape:true, recreateForm: true, width:400,height:200},
{closeOnEscape:true, recreateForm: true, beforeShowForm: function(formId){var cm = $('#list10_d2').jqGrid('getColProp',"PROTOCOL_ID"); cm.editable=false; var cm2 = $('#list10_d2').jqGrid('getColProp',"STAGE_ID"); cm2.editable=true; alert("before");}, addData:{action:'protocolStageAdd',protID: function () {return protID;}, stageID: function(){return stageID;}},width:500,mtype:'POST', url: 'ProtocolJGridServChildStages',closeOnSubmit: true},
{closeOnEscape:true, recreateForm: true, mtype: 'POST',url: 'ProtocolJGridServChildStages',delData: {action: 'protocolStageDelete',protID: function () {return protID;}, stageID: function(){return stageID;}}});