Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
225
How To: Get column header text for a hierarchy linked to data cell double-click
posted

I worked through the docs/sample code and couldn't seem to figure this out. He have a use case where a user clicks into a cell and we generate something that uses the column header. Here is the scenario:

 

 

When the user double-clicks the 143,762,200 cell I use the MSFT part of the hierarchy to indicate what kind of action to do next and then use the BCY field as a field in that action.

Here is where I am:

 

   var xcell = pivotGrid.SelectionSettings.SelectedCells.FirstOrDefault();

 

This gives me the cell however there seems to be no easy way to get the correlated column header parts. I poked around in the DataColumn and DataRow to no avail.

 

Thanks,Damon

 

 

Parents
No Data
Reply
  • 7922
    Suggested Answer
    posted

    Hi Damon,

    Below is a snippet how to find the members for column and row hierarchies.

    private void pivotGrid_CellClicked(object sender, PivotCellClickedEventArgs e)
    {   
        // find cell location    
        int columnIndex = pivotGrid.DataColumns.IndexOf(xcell);
        int rowIndex = pivotGrid.DataRows.IndexOf(xcell);
     
        // extract the tuples  
        ITuple columnTuple = pivotGrid.DataSource.Result.ColumnAxis.Tuples[columnIndex];
        ITuple rowTuple = pivotGrid.DataSource.Result.RowAxis.Tuples[rowIndex];
     
        // accordance between members and hierarchy  
        // columnTuple.Members[i] = pivotGrid.DataSource.Columns[i];  
     
        // from members list you can find the hierarchy 
        IDimension dimension = columnTuple.Members[0].ParentLevel.ParentHierarchy.ParentDimension;
    }

    Regards
    Todor

Children
No Data