radio button - Ext JS 6.2 - Not able to get the selected value from radiobutton -
there 2 radio buttons display 2 different chart in screen. default first radio button. means when screen loading, it's display first radio button chart default. until this, code working fine. issue is, when selecting second radio button, again prints first radio button value in controller instead of radio button value. in browser console area, able view corresponding second radio button values.please me in this.
ext.componentquery.query('#myselection')[0].getchecked()[0].inputvalue;
controller.js
init: function() { this.control({ 'radiobuttoncomp #myselection' : { change : this.onmetricschanged } }); }, onmetricschanged : function(radioid, newvalue, oldvalue, eopts){ var compid = ext.componentquery.query('#myselection')[0]; var selectedradioval = compid.getchecked()[0].inputvalue; console.log('selected value: ' + selectedradioval+'==sel===='+ext.componentquery.query('#myselection')[0].getchecked()[0].inputvalue); }
radiobuttoncomp.js
ext.define('gmis.view.general.radiobuttoncomp', { extend: 'ext.form.panel', xtype: 'radiobuttoncomp', config:{ metriclabels : null, metricvalues : null, selectionvalue : null }, constructor: function(cfg){ ext.apply(this, cfg); //this.initconfig(cfg); this.callparent(); }, width: '100%', height: 20, bodypadding: 0, border:false, bodystyle:{ 'background-color':'#fbfbfb' }, layout:{ type: 'hbox', pack: 'end' }, initcomponent : function(){ var me = this; var label = this.metriclabels.split('~'); var vals = this.metricvalues.split('~'); var selectval = this.selectionvalue.split('~'); var radiobtn1; var radiobtn2; console.log('=====selectval====='+selectval); console.log('=====selectval[0]====='+selectval[0]); console.log('======selectval[1]======'+selectval[1]); if(selectval[0]=='true'){ radiobtn1 = true; }else{ radiobtn1 = false; } if(selectval[1]=='true'){ radiobtn2 = true; }else{ radiobtn2 = false; } me.items=[{ xtype: 'radiogroup', fieldlabel: '', columns: 2, vertical: false, itemid: 'myselection', width: 280, style:{ 'background-color':'#fbfbfb' }, items: [ { boxlabel: label[0], name: 'metric', inputvalue: vals[0], checked: radiobtn1, simplevalue: true, style:{ 'background-color':'#fbfbfb', font: 'bold 11px helvetica' } }, { boxlabel: label[1], name: 'metric', inputvalue: vals[1], checked: radiobtn2, simplevalue: true, style:{ 'background-color':'#fbfbfb', font: 'bold 11px helvetica' }} ] }]; this.callparent(); } });
Comments
Post a Comment