PDA

View Full Version : Trying to display the record count of grid



kumar_Rajesh78
12 Mar 2015, 10:18 AM
Hello everybody,
I am trying to figure out how to display the total record count of the grid on my extjs 4 page.
I am using the following code and put it under listener.


afterRender: function() {
var me = this;
me.callParent(arguments);
me.store.on('load', function(records) {
var count = me.store.getTotalCount(); //or store.getTotalCount(), if that's what you want
var recordCountText = Ext.ComponentQuery.query('#totalPortfolioCount')[0];
console.log(count);
recordCountText.setText('Total Number of Portfolios: ' + count);
})


This works fine first time when the store loads, but when I reload the store, it does not kick off and the total number of records dont get displayed.
What is the mistake that I am doing, or is there an alternative way of doing it.

I tried other grid events, like render, viewready, but none of these get triggered on the second load.

Please advise,
I would really appreciate the help.

Thanks in advance,
Rajesh

kishorkoli8
13 Mar 2015, 12:55 AM
try this,

store.getCount();

joel.watson
14 Mar 2015, 6:38 PM
Hello everybody,
I am trying to figure out how to display the total record count of the grid on my extjs 4 page.
I am using the following code and put it under listener.

This works fine first time when the store loads, but when I reload the store, it does not kick off and the total number of records dont get displayed.
What is the mistake that I am doing, or is there an alternative way of doing it.

I tried other grid events, like render, viewready, but none of these get triggered on the second load.

Please advise,
I would really appreciate the help.

Thanks in advance,
Rajesh

Without seeing your code in totality, it's tough to tell. However, I put together an example which should work (see Fiddle below).

Thanks
Joel

jkf