PDA

View Full Version : cann't load the buttons to the tool bar, is "lazy load" cause this problem?



lzqlawrence
9 Aug 2011, 11:41 PM
hi all,


var toolbarStore = new Ext.data.Store({
proxy: new Ext.data.HttpProxy({method: 'POST', url:'user/userListAction!buttonList.action'}),
reader: new Ext.data.JsonReader({
totalProperty:'totalProperty',
root:'root'
},
Ext.data.Record.create([
{name: 'display', type:'string'},
{name: 'url', type:'string'}
])
)
});
var toolbar2 = new Ext.Toolbar({
});
toolbarStore.load();

// alert("--cc--" + toolbarStore.getTotalCount());

toolbar2.add('->');
toolbarStore.each(function(record) {
toolbar2.add({
xtype: 'button',
text: record.get('display')
},'-');
});
var grid = new Ext.grid.GridPanel({
renderTo:'userGrid',
store:ds,
cm: cm,
viewConfig:{forceFit:true},
autoHeight: true,
autoWidth:true,
tbar:toolbar2,
bbar: new Ext.PagingToolbar({
pageSize: 15,
store: ds,
displayInfo: true,
displayMsg: 'Displaying records {0} to {1} of {2} records..',
emptyMsg: "No records to display"
})
});
ds.load({params:{start:0, limit:15}});

if "alert("--cc--" + toolbarStore.getTotalCount());" is commented, the buttons cannot be shown in the toolbar, but if "alert("--cc--" + toolbarStore.getTotalCount());" is uncommented, the buttons can be shown. why? lazy load? or something else? plz give me some tips, thanks. ExtJS-3.3.1

danguba
10 Aug 2011, 3:40 AM
Load method is asynchronous. Add load event listener on store and do stuff in it