Get Free Trial

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

Resolved
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? 
 
Thanks!

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

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

3 answers

Public
Illia Yatsyshyn Illia Yatsyshyn Flexmonster February 24, 2021

Hello,
 
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: https://jsfiddle.net/flexmonster/mfepzjv3/.
 
Please let us know if it works for you.
Our team is looking forward to hearing your feedback.
 
Regards,
Illia

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

Hello,
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!

Public
Illia Yatsyshyn Illia Yatsyshyn Flexmonster February 25, 2021

Hello,
 
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,
Illia

Please login or Register to Submit Answer