javascript - How to disable a particular row in Picker in Sencha touch -
i have created picker in sencha touch 2.1. data displaying properly. want disable particular value not if select value , click "donebutton" shouldn't taken.
example:
function loadpicker(paramname, valueset) { ext.viewport.remove(ext.getcmp(paramname + 'pickerfield'), true); if (!paramname.picker) { paramname.picker = ext.viewport.add({ xtype: 'picker', id: paramname + 'pickerfield', usetitles: true, slots: [{ name: paramname, title: paramname, data: valueset }], donebutton: { listeners: { tap: function(button, event, eopts) { var selectedpacingmodevalue = ext.getcmp(paramname + 'pickerfield').getvalue()[paramname]; sendsetpendingrequest(paramname, selectedpacingmodevalue); } } } }); } }
lets take these values in picker field. doing on select of value , click of "donebutton", showing value in textfield. want if select "option 2" , click "donebutton" option 2 shouldn't displayed in textfield other values selecting , showing in textfield operation should work.
you can selected record , check flag upon click of done button, move textbox (or not).
ext.create('ext.form.panel', { fullscreen: true, items: [ { xtype: 'fieldset', title: 'select', items: [ { xtype: 'selectfield', itemid: 'myselectfield', label: 'choose one', options: [ { text: 'apple', value: 50 }, { text: 'orange', value: 100, disabled: true }, { text: 'banana', value: 200 }, { text: 'papaya', value: 300 } ] }, { xtype: 'button', text: 'done', handler: function(button){ var panel = button.up(), sf = panel.down('#myselectfield'), tf = panel.down('#answerfield'); /* can access raw value unless use * actual store , actual model * disabled field. in case can * sf.getrecord().get('disabled') */ if(sf.getrecord().raw.disabled === true){ tf.setvalue(''); //noting see :) } else { tf.setvalue(sf.getrecord().get('text')); //display value } } }, { xtype: 'textfield', itemid: 'answerfield', title: 'answer' } ] } ] });
working fiddle: http://www.senchafiddle.com/#d46xz
update asked: picker
ext.loader.setconfig({ enabled: true }); ext.application({ name: 'senchafiddle', launch: function() { var picker = ext.create('ext.picker', { slots: [ { name : 'stuff', title: 'stuff', data : [ { text: 'apple', value: 50 }, { text: 'orange', value: 100, disabled: true }, { text: 'banana', value: 200 }, { text: 'papaya', value: 300 } ] } ], listeners: { change: function(p, value){ var tf = panel.down('#answerfield'), firstslot = p.getitems().get(1), //index 0 toolbar 1 first slot , on.. selectedrecord = firstslot.getdata()[firstslot.selectedindex]; if(selectedrecord.disabled === true){ tf.setvalue(''); //noting see :) } else { console.log(selectedrecord); tf.setvalue(selectedrecord.text); //display value } } } }); var panel = ext.create('ext.form.panel', { fullscreen: true, items: [ { xtype: 'fieldset', title: 'select', items: [ { xtype: 'button', text: 'show picker', handler: function(button){ ext.viewport.add(picker); picker.show(); } }, { xtype: 'textfield', itemid: 'answerfield', title: 'answer' } ] } ] }); } });
working fiddle: http://www.senchafiddle.com/#sfgpv
Comments
Post a Comment