PDA

View Full Version : Set displayfield of combo and binding its store dyanamically



DevPatil
31 Oct 2014, 12:37 AM
I am facing a weird issue.I am trying to change the store of combo by using bindStore() and also changing the displayfield and valuefield dyanamically.The store is getting binded for the first time but I am not able to select any value from the picklist.Also on changing the value of 1st combo, store is not getting binded properly.
Here is the sample fiddle : https://fiddle.sencha.com/#fiddle/ck4
(In the above fiddle, I am trying to set the respective displayfield based on the value selected in 1st combobox.)
Note: Above scenario matches my requirement.
Please help me resolve the issue.Please correct me if I am going wrong somewhere.:-|

DevPatil
31 Oct 2014, 1:01 AM
bindStore() is suitable for changing data only provided that its fields are the same.
Reference : http://www.sencha.com/forum/showthread.php?194151-Dynamic-store-assignment-to-combobox

I need to destroy some members.Here is the solution.

Ext.destroyMembers(combobox, 'displayTpl');
combobox.displayTpl = Ext.create('Ext.XTemplate',
'<tpl for=".">' +
'{[typeof values === "string" ? values : values["' + combobox.displayField + '"]]}' +
'<tpl if="xindex < xcount">' + combobox.delimiter + '</tpl>' +
'</tpl>'
);
Ext.destroyMembers(combobox, 'picker');