jqGrid select dropdown element

14,030

You can use an additional searchoptions option

searchoptions:{
    dataInit:function(el){
        $("option:contains("+defaultCategory+")",el).attr("selected", "selected");
        setTimeout(function(){
            $(el).trigger('change');
        },500);
    }
}

where defaultCategory is the option which you want have default. See small demo here.

Share:
14,030
bignermo
Author by

bignermo

Updated on June 04, 2022

Comments

  • bignermo
    bignermo almost 2 years

    I am struggling to select, and manipulate, the dropdown from the jqGrid.

    jQuery("#grid")...
    
    colModel: [...
    
    { name: 'StateId', index: 'StateId', width: 350, align: 'center', stype: 'select',
      edittype: 'select', searchoptions: { sopt: ['eq'] },
      editoptions: { value: controllerMethods.GetStates()} },...
    
    .
    .
    .    
    
    jQuery("#grid").jqGrid('filterToolbar', { stringResult:true, searchOnEnter:false });
    

    I simply need to be able to set a default selected value of the dropdown control and I am unable to achieve that :(

    Any help is appreciated!