the selected value was cleared in dropdown after a

2019-06-11 17:33发布

问题:

In jqgrid advanced searching, the value selected in drop down list was cleared after i add new criteria.

Below detail for your reference.

1) in jqgrid column model

{name:'instrumentType', 
 index:'instrumentType',
 searchoptions:{
                dataInit:instrumentTypeDataInit,
                sopt: ['eq','ne','nu','nn','in','ni']},    
 align:"left", 
 stype:'select'},

2) javascripts function for instrumentTypeDataInit

instrumentTypeDataInit=function(el){
    var categoryInstrumentTypeOptions = "${categoryInstrumentTypeOptions}";  
    $(el).append(categoryInstrumentTypeOptions);
  }

3) when add criteria "Instrument Type", and select "OPTION", it goes well.

4) when add another criteria, the value selected is cleared.

Does anyone know why it is? and what's the solution? thanks a lot.

EDIT:

i've used the dataInit function in the wrong way, used searchOptions.value instead, the issue has been resolved, you can refer another post:best way to dynamically populate dropdown options in jqgrid advanced searching

回答1:

i've used the dataInit function in the wrong way, used searchOptions.value instead, the issue has been resolved, you can refer another post, Oleg has given an answer: