PDA

View Full Version : Panel items add based on Store



qt4x11
14 Mar 2012, 10:37 AM
Ext.define('Ext.company.EditCompany', {
extend : 'Ext.panel.Panel',
alias : 'widget.company-EditCompany',


title : 'Edit Companies',
closable : true,
closeAction : 'hide',
layout : {
type : 'vbox',
align : 'stretch'
},
items : [ {
xtype : 'company-EditCompanyGrid',
flex : 1


} ],


initComponent : function() {
this.store = Ext.create('Ext.data.Store', {
model : 'Ext.company.EditCompanyModel',
root : {
expanded : true
},
proxy : {
type : 'ajax',
url : '/servlet/CompanyServlet?action=companyList'
},
folderSort : true,
autoLoad : true
});


this.callParent(arguments);
}


});


I am not sure how to do this. I have a Panel that contains a single item which is a GridPanel. This panel also has a store. What I'd like to do is something like this.store.getCount() - and based on the value of 'count' - display either one item or another item in the Panel.

So something like
var count = this.store.getCount();
if (count == 1)

items : [ {
xtype : 'company-EditCompanyGrid',
flex : 1


else

items : [ {
xtype : 'company-EditCompanyGrid2',
flex : 1

--any suggesetions? Thanks

mitchellsimoens
14 Mar 2012, 11:30 AM
Add items to the panel after the store has loaded.