How to get cell position of the row header in PivotGrid?
This KB article explains how to get the cell position of row header in the PivotGrid component.
Solution
You can get the index of row header using JSON records.
Step 1
Enable row header hyperlink (enableRowHeaderHyperlink) and trigger the “rowHeaderHyperlinkClick” event.
JS
$("#PivotGrid1").ejPivotGrid(
{
url: "/Olap", hyperlinkSettings: {enableRowHeaderHyperlink: true}, rowHeaderHyperlinkClick: "rowHeaderClick"
});
MVC
@(Html.EJ().Pivot().PivotGrid("PivotGrid1") .Url(Url.Content("~/api/Olap")) .HyperlinkSettings(hl=>hl.EnableRowHeaderHyperlink(true)) .ClientSideEvents(cl=>cl.RowHeaderHyperlinkClick("rowHeaderClick")))
ASP
<ej: <ej:PivotGrid ID="PivotGrid1" runat="server"> <HyperlinkSettings EnableRowHeaderHyperlink="true"/> <ClientSideEvents RowHeaderHyperlinkClick="rowHeaderClick"></ClientSideEvents> </ej:PivotGrid> <asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager>
Step 2
Find the position of row header using JSON records.
JS
function rowHeaderClick(event) {
var pivotGridObj = $("#PivotGrid1").data("ejPivotGrid");
var rowHeader = event.args.cellValue; //Get the current row header
// Get the row header position using JSON records.
var JSONRecords = pivotGridObj.getJSONRecords();
for (var j = 0; j < JSONRecords.length; j++) {
if (!ej.isNullOrUndefined(JSONRecords[j].Value) && JSONRecords[j].Value == rowHeader){
var rowHeaderPosition = JSONRecords[j].Index;
break;
}
}
Conclusion
I hope you enjoyed learning about how to get cell position of the row header in MVCPivotGrid.
You can refer to our PivotGrid's feature tour page to know about its other groundbreaking feature representations and documentation, and how to quickly get started for configuration specifications.
For current customers, you can check out our MVC controls from the License and Downloads page. If you are new to Syncfusion, you can try our 30-day free trial to check out our other controls.
If you have any queries or require clarifications, please let us know in the comments section below. You can also contact us through our support forums, Direct-Trac, or feedback portal. We are always happy to assist you!