Set drop down menu selected value in .js file

Hello there,

How to set drop down menu selected value in .js file when the view is load?

Thanks!!

  • Hi Sugardeveloper11,

    You can set dropdown value as selected like how we will set value for a  field.Then call that function in render of view.

    below is the code snippet,

    channel_c - Dropdown field

    Life - KeyValue ( Not Display label)

    initialize:function(options){

    this._super('initialize',[options]);

    this.on('render',this._setValue,this);

    },

    _setValue:function(){

         //this.model.set('dropdown_field',"value");

         this.model.set('channel_c',"Life");

    }

    Thanks!.