🍉 Meet Flexmonster Pivot Table & Charts 2.9.Check out all hot features!
Get Free Trial

How to count number of row and column ?

Patrick TAVARIS asked on November 6, 2019

I need to be able to grab values of all totalCol/rows cells.
First I have tried to use customizeCellFunction but I realized that this method is called only when the cells are drawn. If the pivoTable is  big and contains scrollbars, I won’t be able to use this custmzeCellFunction to grab my values on page load.
So I found aftergriddraw event which sounds to be the good place to know when the dataset and flexmonster table is loaded.
In this event caught, I need to use getCell() to grab requested values but here is the issue. I don’t know how to grab the rows count and column count to getCell() only on the total rows+cols.
How can I do that ?
Maybe there is another way to get total cells values aftergriddraw ? (without being forced to scroll the pivotTable front end side)

3 answers

Vera Didenko Vera Didenko Flexmonster November 6, 2019

Thank you for writing to us.
For your case, we kindly suggest using the getData() API call:

1) You can pass a separate slice to getData() with only measures specified:  http://jsfiddle.net/flexmonster/0eujakf9/
This way it will be easier to get the grand total values.

2) Also, you can pass a default slice to getData() and retrieve any other needed data values: http://jsfiddle.net/flexmonster/dhos9py3/
Please let us know if you have any questions.
Best Regards,

Patrick TAVARIS November 7, 2019

Hi Vera,
I don’t see any clue in your jsfiddle sample neither with usage of getData().
What i want to do is when reportcomplete() event is caught, determinate total number of rows in the pivotTable (already displayed or not due to a potential scrollbar).
Then with this number retrieved, I can call getCell on this last line and do what I need to do for the purpose of my app.
Am I making sense ?
So I have to keep using getCell() blindly (currently) until I find the lastRow+1 telling me it is not filled.
I hope you will have a better idea for me.

Vera Didenko Vera Didenko Flexmonster November 8, 2019

Thank you for your reply and for providing more details regarding your case.
Flexmonster has special API calls for retrieving the total grid column count:


and grid row count:


Here is a JSFiddle example for illustration: https://jsfiddle.net/flexmonster/whacdLyj/
Please let us know if this helps.
You are welcome to write to us in case you need further details.
Best Regards,

Please login or Register to Submit Answer