TTT
17 Jun 2008, 10:59 PM
have a simple code:
var GridUI = function() {
var list_ds;
var list_grid;
var list_columnModel;
var list_gridForm;
var list_count;
function list_buildGrid() {
list_ds = new Ext.data.Store({
proxy: new Ext.data.HttpProxy({url:'/cgi-bin/profiles/get_table.cgi'}),
reader: new Ext.data.JsonReader(
{root: 'data',totalProperty: 'count'},
[
{name: 'ID_GLOBAL',type:'int'},
{name: 'comp_name',type:'string'}
]
)
});
list_ds.load();
if(!list_columnModel) {
list_columnModel = new Ext.grid.ColumnModel(
[
{
header:'ID',
dataIndex:'ID_GLOBAL',
sortable:true,
width:50
},
{
header:'Comp_name',
dataIndex:'comp_name',
sortable:true,
width:195,
css:'white-space:normal;'
}
]
);
}
list_grid = new Ext.grid.EditorGrid('list',
{
ds:list_ds,
cm:list_columnModel,
autoExpandColumn:'1',
enableColLock:false,
selModel: new Ext.grid.RowSelectionModel({singleSelect:true}),
loadMask: true
}
);
list_grid.render();
var list_gridHeaderPanel = list_grid.getView().getHeaderPanel(true);
var list_tb_top = new Ext.Toolbar(
list_gridHeaderPanel,
[
{
text: 'Count:' + list_ds.getTotalCount() + '.', // #1
handler: function(){
alert(list_ds.getTotalCount()); // #2
}
}
]
);
alert(list_ds.getTotalCount()); // #3
}
return {
init : function() {
list_buildGrid();
}
}
} ();
Ext.onReady(GridUI.init, GridUI);
#1 and #3 shows zero, but when pressed the button (#2) popup shows the current number of loaded rows. Why?
var GridUI = function() {
var list_ds;
var list_grid;
var list_columnModel;
var list_gridForm;
var list_count;
function list_buildGrid() {
list_ds = new Ext.data.Store({
proxy: new Ext.data.HttpProxy({url:'/cgi-bin/profiles/get_table.cgi'}),
reader: new Ext.data.JsonReader(
{root: 'data',totalProperty: 'count'},
[
{name: 'ID_GLOBAL',type:'int'},
{name: 'comp_name',type:'string'}
]
)
});
list_ds.load();
if(!list_columnModel) {
list_columnModel = new Ext.grid.ColumnModel(
[
{
header:'ID',
dataIndex:'ID_GLOBAL',
sortable:true,
width:50
},
{
header:'Comp_name',
dataIndex:'comp_name',
sortable:true,
width:195,
css:'white-space:normal;'
}
]
);
}
list_grid = new Ext.grid.EditorGrid('list',
{
ds:list_ds,
cm:list_columnModel,
autoExpandColumn:'1',
enableColLock:false,
selModel: new Ext.grid.RowSelectionModel({singleSelect:true}),
loadMask: true
}
);
list_grid.render();
var list_gridHeaderPanel = list_grid.getView().getHeaderPanel(true);
var list_tb_top = new Ext.Toolbar(
list_gridHeaderPanel,
[
{
text: 'Count:' + list_ds.getTotalCount() + '.', // #1
handler: function(){
alert(list_ds.getTotalCount()); // #2
}
}
]
);
alert(list_ds.getTotalCount()); // #3
}
return {
init : function() {
list_buildGrid();
}
}
} ();
Ext.onReady(GridUI.init, GridUI);
#1 and #3 shows zero, but when pressed the button (#2) popup shows the current number of loaded rows. Why?