Getting the dimension a user just clicked on

Discussion forum for PivotCube VCL users. Common questions. Bug and problem reports

Moderator: Alex Zencovich

Getting the dimension a user just clicked on

Postby Matt Dee » Fri May 18, 2007 12:42 am

Code: Select all
procedure TOLAP.PivotGridColumnHeaderClick(Sender: TObject; X,
  Y, ColIndex, RowIndex: Integer; Cell: PHeaderCell);
var
  i: integer;
begin
  inherited;
  i := Cell^.DimIndex;
  Label1.Caption := PivotMap.Dimensions[i].AliasName;
end;


The above code gives totally wrong dimension names - is there a way to determine what Dimension a user has clicked on? Ideally I need the exact dimensional item (i.e. if the dimension is Customer Age, I want to know what age band they clicked on.)

Cheers,

Matt.
Matt Dee
User
 
Posts: 15
Joined: Sun Nov 05, 2006 9:11 pm

Postby Matt Dee » Fri May 18, 2007 4:00 am

Ok, a stupid oversight on my part :), and I've now managed to get this working with RowHeaders:

Code: Select all
procedure TOLAP.PivotGridRowHeaderClick(Sender: TObject; X, Y,
  ColIndex, RowIndex: Integer; Cell: PHeaderCell);
var
  i: integer;
begin
  inherited;
  i := Cell^.DimIndex;
  Label1.Caption := PivotMap.Rows[i].Dimension.AliasName +
                    ' ' +
                    Cell^.Text;
end;


This works perfectly - I get the dimension as well as the individual dimension value that the user clicked on.

For some reason I cannot get this to work when I move the code to the OnColumnHeaderClick event and use PivotMap.Columns[x] Any idea how to go about that? Not really a big issue, as the type of dimension I'm interested in will nearly always be used as a row.

Cheers,

Matt.
Matt Dee
User
 
Posts: 15
Joined: Sun Nov 05, 2006 9:11 pm

Postby AlexZencovich » Fri May 18, 2007 6:31 am

Please note, OnColumnHeaderClick return pointers to measure and view cells too, so you should move back by PivotGrid.Columns (from Cell.Position) until not enter to COlumns[Cell.Index] with CellType = hctCell
Best regards,

Alex Zencovich
-------------------------------------------------------------------------------------------------------------------------------------------
www.pivotcube.com - OLAP solution for Delphi, C++ Builder and ActiveX environment
AlexZencovich
Site Admin
 
Posts: 580
Joined: Sun Jun 18, 2006 10:09 am


Return to PivotCube VCL

Who is online

Users browsing this forum: No registered users and 0 guests

cron