0

I'm using a jqGrid. For add popup for combobox i'm using default data from the database which works fine. But when edit popup is displayed its not showing the selected value in combobox instead showing 1st value in the list specified.

The following is my code:

$("#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
);
});

If i use dataUrl istead of value in editoptions of column 'PRIMARY_SOURCE_ID' then firebug is throughing an error

options.value is undefined
[Break On This Error] var so = options.value.split(";"),sv, ov;

Please help... How to get selected value in combobox for edit window.

Thanks in advance, Sandeep Vemula

Oleg
  • 220,925
  • 34
  • 403
  • 798
Sandeep
  • 2,041
  • 21
  • 34
  • I recommend you to remove [deprecated](http://www.trirand.com/jqgridwiki/doku.php?id=wiki:upgrade_from_3.4.x_to_3.5) `imgpath` parameter, replace the parameter `pager: $('#pager')` to `pager:'#pager'`, change the value of `sortname` parameter from `sortname: 'user'` to the name of some columns which you use and remove default parameters `multiselect:false`, `mtype: 'GET'` and `datatype: 'xml'`. Setting of additional parameter `height:'100%'` can be helpful. – Oleg May 05 '11 at 12:33

2 Answers2

0

I would recommend you to use dataUrl instead of value in editoptions and additionally use buildSelect (see here) which allows you to simplify the interface of the corresponding action which provide the data for the dataUrl. If you use dataUrl you should remove value definition from the editoptions.

If you will continue to have some problems you can post the current code which you use and which follows to the error.

Community
  • 1
  • 1
Oleg
  • 220,925
  • 34
  • 403
  • 798
0

Just needed to add formatter:"select" option to the column in which i want to display combobox with selected value in edit form.

Sandeep
  • 2,041
  • 21
  • 34