Override for the _getColumnInfo method of the Table Data Model.
/* This is a method override for the _getColumnInfo method
* of the Table Data Model, which provides the table editor with
* information about the column labels. Parameters passed to this method:
* 'rcdvecid' - Use instance of the Row/Column data vector.
* The information about the requested column is
* set on the data vector. */
GETCOL: method rcdvecid 8;
/* Retrieve the value of the instance variable DATABASE
* which contains the information for this multi-dimensional example.
* From the DATABASE list, retrieve the COLUMNS sublist which
* contains the information about the columns. Within the COLUMNS
* list, the columns are stored in order starting at the beginning
* of the list. For example, the first column, CANADA, in the
* COLUMNS list is the first column to display in the table
* editor. */
database = getniteml( _self_, 'DATABASE' );
columnlst = getniteml( database, 'COLUMNS' );
/* Use the _getCoordinates method of the Row/Column Data Vector
* to retrieve which column is currently being requested by the
* table editor for display. */
coords = makelist();
call send(rcdvecid, '_getCoordinates', coords );
/* Get the top-level column dimension from the COORDS list */
colnum = getitemn( coords, 1 );
/* Retrieve the second-level column dimension if available on the
* COORDS list. */
if ( listlen( coords ) > 1) then
subcolnum = getitemn( coords, 2 );
else
subcolnum = 0;
/* Retrieve the third-level column dimension if available on the COORDS
* list. */
if ( listlen( coords ) > 2 ) then
subsubcolnum = getitemn( coords, 3 );
else
subsubcolnum = 0;
/* The COORDS list is no longer needed. Delete the COORDS list. */
coords = dellist( coords );
/* Determine the label for the column to be displayed. */
/* If Table Editor has requested three dimensions... */
if ( subsubcolnum ) then
do;
/* Using the top-level column dimension(COLNUM), retrieve the
* top-level dimension list from COLUMNS. For example, if
* COLNUM is 1, then the sublist CANADA would be retrieved
* from the COLUMNS list. */
columnlst = getiteml( columnlst, colnum );
/* Using the second-level column dimension(SUBCOLNUM), retrieve the
* second-level dimension list from top-level list. For
* example, if SUBCOLNUM is 2 and the top-level list was
* CANADA, then the sublist CONSUMER would be retrieved from
* the CANADA list. */
columnlst = getiteml( columnlst, subcolnum );
/* Since the last requested level is the third-level dimension,
* you need retrieve the column label by getting the
* value of the SUBCOLNUM item from the top-level list. */
label = getitemc( columnlst, subsubcolnum );
end;
/* If Table Editor has requested two dimensions... */
else if ( subcolnum ) then
do;
/* Using the top-level column dimension(COLNUM), retrieve the
* top-level dimension list from COLUMNS. For example, if
* COLNUM is 1, then the sublist CANADA would be retrieved
* from the COLUMNS list. */
columnlst = getiteml( columnlst, colnum );
/* Since the last requested level is the second-level dimension,
* you need retrieve the column label by getting the
* name of the SUBCOLNUM item from the top-level list. */
label = nameitem( columnlst, subcolnum );
end;
/* If Table Editor has requested one dimension... */
else
/* Since the last requested level is the top-level dimension,
* you need retrieve the column label by getting the
* name of the COLNUM item from the COLUMNS list. */
label = nameitem( columnlst, colnum );
/* Set the label on the Row/Column Data Vector for the column. */
call send( rcdvecid, '_setText', label );
endmethod;