clear getRowsNum

I am using paging in a statusBar with my Grid. I am then creating and appending a child element (div) to it and displaying the number of records returned by the getRowsNum method.

 function setCounter(){
    var paging = document.getElementById('pagingArea');
    var record = document.createElement('div');
    var count = appGrid.getRowsNum();
    record.innerHTML = " Record Count: "+count;
    paging.appendChild(record);
  }

The Grid records (xml) change with a combo selection. I use atattachEvent(“onXLE”, setCounter) to call the the setCounter function when the grid is first loaded and, on any change to the Grid (it is called after each grid.load). This all works great on the first call to setCounter() but, the displayed record count stays the same for any subsequent calls. The paging works fine as does the Grid but the record count never changes until the Grid/page is reloaded. Whatever the first count is on the initial load of the grid, is what it remains as.

I have tried unsuccessfully (separately and together):

 var count = '';
 count = getRowsNum();

and

 record.innerHTML = '';
 record.innerHTML = " Record Count: "+count;

I know for Grid there is the clearAll() method to clear the existing records from a grid before loading new ones, it there not something similar for the getRowsNum()? If not, how can I clear the count and display a current one?

Unfortunately there is no method for clearing the getRowsNum() method as it always returns the actual number of row in the grid.

Please, note that in your setCounter() function the “record” is a local variable and it’s not accessible outside your function.

If the problem still occurs for you please, provide with a complete demo or a demo link, where the issue can be reproduced locally.

Sematik,
Thank you for the response. I have not been able to resolve the issue and have attached a demo as you requested.

In the demo I have included an alert("Count "+count) in the setCounter function to display the correct record number that is being loaded into the grid, but the Counter in the paging area never changes from the initial count value.

Also, please notice the number of alerts increments by one for each selection you make until the page is reloaded. Why?

Thank you for your help.

Stacey
demo_files.zip (3.24 KB)

Please, refer to the attached modified html.
It works well for me.
grid.zip (1.09 KB)

Sematik,
It works perfectly. Thank you. I have only been working with DHTMLX for a couple of months.

I see that you moved the “attachEvent(“onXLE”, setCounter)” outside the other attachEvent I had it in. I had not thought of that.

One thing I don’t quite understand is the “myToolbar=myGrid.aToolBar”. Could you please explain this for me?

Thank you again for your assistance.

Stacey

I see that you moved the “attachEvent(“onXLE”, setCounter)” outside the other attachEvent I had it in. I had not thought of that.
it is not recommended to call the attachEvent inside another attach event, as it most probably will cause a recursion.

One thing I don’t quite understand is the “myToolbar=myGrid.aToolBar”. Could you please explain this for me?
Sure, sorry that didn’t clarify.
It is a common way to customize a toolbar paging. Here is the tutorial:
docs.dhtmlx.com/grid__paging.htm … oolbarskin