PDA

View Full Version : work of combobox and button



neosky
11 Apr 2014, 4:31 AM
Hello i am have form with combobox and button. When in combobox something select then button is enabled, but when in combobox nothing select then button is disabled. Some times i am reload store and store what load in combobox is empty, but in combobox load one record with text: "( price/pcs. )" and then button is enabled although store is empty and combobox is empty also. What to do to become a button is disable and combobox is empty when reload empty store? Thanks


var Text = '{book} ({year} {price} ( price/pcs. ))';

{
xtype: 'combobox',
width: 350,
store: 'Books',
queryMode: 'local',
tpl: Ext.create('Ext.XTemplate',
'<tpl for=".">',
'<div class="x-boundlist-item">' + Text + '</div>',
'</tpl>'),
displayTpl: Ext.create('Ext.XTemplate',
'<tpl for=".">',
Text ,
'</tpl>'),
valueField: 'id',
name: 'Books',
disable:'false',
listeners: {
select: function(combo) {
if (this.getValue() === null) {
Ext.getCmp('books_all').setDisabled(true);
}
else {
Ext.getCmp('books_all').setDisabled(false);
}
}
}
},

Zinnia
14 Apr 2014, 12:47 AM
On render of combo, check if the combo store is empty or not. if the combo store is empty then disable the button

neosky
15 Apr 2014, 3:36 AM
about this:


render: function(combo) {
if (Ext.getCmp('books_all_combo').getStore().getCount() == '0')
{
Ext.getCmp('books_all_button').setDisabled(true);
}
else {
Ext.getCmp('books_all_button').setDisabled(false);
}}