【发布时间】:2011-05-05 11:46:11
【问题描述】:
我正在使用 jqGrid。对于为组合框添加弹出窗口,我使用数据库中的默认数据,效果很好。 但是当显示编辑弹出窗口时,它不会在组合框中显示选定的值,而是在指定的列表中显示第一个值。
以下是我的代码:
$("#list").jqGrid({
url:'<%=request.getContextPath()%>/getDetail.jsp',
datatype: 'xml',
mtype: 'GET',
colNames:['DataChannel ID','Description','Date Creation(MM/dd/yyyy)','Date Closure(MM/dd/yyyy)','Frequency','Source Type','Source Data Type','Primary Data Source','Secondary Data Source','Data Available From(MM/dd/yyyy)','Lag','Advance Alert','Confidentiality Type','Data Flow Type','PSM Name','Comment','Data Available Upto(MM/dd/yyyy)'],
colModel :[
{name:'DESCRIPTION', index:'DESCRIPTION',editable:true,editrules:{required:true}, width:120},
{name:'DATE_CREATION', index:'DATE_CREATION', editable:true,editrules:{required:true}, width:80},
{name:'DATE_CLOSURE', index:'DATE_CLOSURE', editable:true,width:80},
{name:'PRIMARY_SOURCE_ID', index:'PRIMARY_SOURCE_ID',editable:true,edittype:"select",
edittype:"select",editoptions:
{dataInit:function(elem){alert(elem);},value:"<%ctr=0;count=sourceList.size();for (itr=sourceList.iterator(); itr.hasNext(); ) {ctr++;sourceMap=(HashMap)itr.next();it = sourceMap.entrySet().iterator();while (it.hasNext()) {pairs = (Map.Entry)it.next();%><%=pairs.getKey()%>:<%=pairs.getValue()%><% if(ctr < count){%>;<%}}}%>"}, width:120},
{name:'DATA_AVAILABLE_UPTO', index:'DATA_AVAILABLE_UPTO',editable:false,width:100}],
pager: $('#pager'),
rowNum:10,
rowList:[10,20,30],
sortname: 'user',
sortorder: "desc",
viewrecords: true,
multiselect:false,
imgpath: '<%=request.getContextPath()%>/themes/steel/images',
caption: 'Data Channel Master Data',
editurl: '<%=request.getContextPath()%>/ChannelUpdate.jsp',
width:1700
}).navGrid('#pager',{add:true,addtext:'Add',edit:true,edittext:'Edit',del:true,deltext:'Del', search:true,searchtext:'Find',refresh:true}, //options
{height:300,width:500,reloadAfterSubmit:true}, // edit options
{height:300,width:500,reloadAfterSubmit:true}, // add options
{reloadAfterSubmit:true}, // del options
{} // search options
);
});
如果我在“PRIMARY_SOURCE_ID”列的编辑选项中使用 dataUrl 而不是值,那么 firebug 会出错
options.value is undefined
[Break On This Error] var so = options.value.split(";"),sv, ov;
请帮助...如何在编辑窗口的组合框中获取选定的值。
提前致谢, 桑迪普维姆拉
【问题讨论】:
-
建议去掉deprecated
imgpath参数,将pager: $('#pager')参数替换为pager:'#pager',将sortname参数的值从sortname: 'user'改为部分列名您使用并删除默认参数multiselect:false、mtype: 'GET'和datatype: 'xml'。设置附加参数height:'100%'会有所帮助。