Get Free Trial

How to get column name and row's first column value

Morales, Julio César Álvaro asked on February 24, 2021

Good Day,
I want to figure out a way to get the selected column name and the first value of the row of which the cell is selected, right now the celldoubleclick event is working okay, but it only brings me the columnIndex and rowIndex.
I would like to have for example (please see the attached image), when I double click the cell [3, 4] to get  the values “COLOR” and “Canada”.
Is there any way to do this easily? 

PivotSummary.on('celldoubleclick', function (cell) {
var obj = {
column: cell.columnIndex,
row: cell.rowIndex - 1

alert(obj.column + " " + obj.row);

3 answers

Illia Yatsyshyn Illia Yatsyshyn Flexmonster February 24, 2021

Thank you for reaching out to us.
To retrieve the column’s name, use the hierarchy property of the Cell Data Object.
The first value of the column can be obtained using the getCell API call with the corresponding arguments.
You are welcome to see the JSFiddle we have prepared for the demonstration:
Please let us know if it works for you.
Our team is looking forward to hearing your feedback.

Morales, Julio César Álvaro February 25, 2021

I made it work with your example, I just made a little change to get the first value of the row:

flexmonster.on("celldoubleclick", data => {
let columnName = data.hierarchy ? data.hierarchy.caption : "Unknown";
let firstValue = flexmonster.getCell(data.rowIndex, 0).label;
alert(columnName + " - " + firstValue);

Other than that it works great, Thanks!

Illia Yatsyshyn Illia Yatsyshyn Flexmonster February 25, 2021

Thank you for your feedback.
Our team is happy to hear the solution works well for you.
Feel free to contact us in case any other questions arise.
Kind regards,

Please login or Register to Submit Answer