PDA

View Full Version : count number of rows in a grid and write result as text in the tab title



robertdbuckley
5 Apr 2011, 7:09 AM
Hi,

I have a grid in a panel. I would like to count how many entries there are and write the number next to the tab title...

e.g

Windturbines (354).

How could I go about getting the nr of rows?


thanks for your help,

Robert

fay
5 Apr 2011, 7:25 AM
grid.getStore().getCount();


This should be done after the store is loaded. So you might want to add a 'load' event handler to your grid's store.

robertdbuckley
5 Apr 2011, 7:36 AM
Brilliant...thanks...

this will give me an integer

and how do I get the number into the tab title next to the original title?

ps...thanks for all the great help!

store_wea.on('load', function(ds){
store_wea.getTotalCount());
});

if
(panel.id == 'WEA') {
gridContainer.getLayout().setActiveItem(grid_wea);
// mapPanel_wea.setTitle(title + count, iconDashboard');

if (w.collapsed) {
w.expand()
}

robertdbuckley
5 Apr 2011, 12:48 PM
Hi,

This code managed to set the title and total count of the grid. However, it only works for the first tab.
I thought this code first activates the tab and resets the title, but it doesnīt.

Can anyone see how to make this work for all tabs when they are activated?

Thanks for your help,

Robert

ps..Where should I paste the code?..for some reason the 50% of this site is in asian text and I canīt understand it.

tab.on('activate',function(panel){

var w = Ext.getCmp('gridContainer');

if
(panel.id == 'WEA') {
mapPanel_wea.setIconClass('icon-tick');
mapPanel_biogas.setIconClass('');
mapPanel_wasser.setIconClass('');

store_wea.on('load', function(ds){
var getcount_wea = store_wea.getTotalCount();
Ext.getCmp('grid_wea').setTitle(panel.title + " " + "(" + getcount_wea+ ")");
});

gridContainer.getLayout().setActiveItem(grid_wea);
if (w.collapsed) {
w.expand()
}
}
else
if (panel.id == 'Biogas') {
mapPanel_wea.setIconClass('');
mapPanel_biogas.setIconClass('icon-tick');
mapPanel_wasser.setIconClass('');

store_biogas.on('load', function(ds){
var getcount_biogas = store_biogas.getTotalCount();
Ext.getCmp('grid_biogas').setTitle(panel.title + " " + "(" + getcount_biogas+ ")");
});

// Ext.Msg.alert('Panel', panel.id + '" tab?');
gridContainer.getLayout().setActiveItem(grid_biogas);
if (w.collapsed) {
w.expand()
}
}
else
if (panel.id == 'Wasserkraft') {
mapPanel_wea.setIconClass('');
mapPanel_biogas.setIconClass('');
mapPanel_wasser.setIconClass('icon-tick');

store_wasser.on('load', function(ds){
var getcount_wasser = store_wasser.getTotalCount();
Ext.getCmp('grid_wasser').setTitle(panel.title + " " + "(" + getcount_wasser+ ")");
});

// Ext.Msg.alert('Panel', panel.id + '" tab?');
gridContainer.getLayout().setActiveItem(grid_wasser);
if (w.collapsed) {
w.expand()
}
}
else

if (panel.id == 'Download') {
mapPanel_wea.setIconClass('');
mapPanel_biogas.setIconClass('');
mapPanel_wasser.setIconClass('');

// Ext.Msg.alert('Panel', panel.id + '" tab?');
if (w.expand) {
w.collapse()

}
}
});

});