Chapter Contents

Previous

Next
SAS/AF Software: Class Dictionary

Using the Table Editor Class


Making a Table Editor

By default, the table editor is not included in the Components window. Therefore, to create a table editor object, do the following:

Once the Table Editor is included in the Components window, you can drag a table editor object from the Components window and drop it on a frame.


Making Selections in Table Editor

The table editor provides features that enable users to select one or more rows or columns in the table. Selection features determine whether multiple selected rows can be noncontiguous, called multiple selections, or contiguous, called an extended selection.

You enable selection features by setting attributes for the table. In addition to determining whether multiple rows or columns can be selected, other attributes determine whether a row can be selected by clicking any of its columns or a row or column can be selected by clicking its label.

Multiple Selections

Multiple selections refers to the ability to select or highlight more than one noncontiguous range of cells. The ability to make multiple selections can be enabled with the table attribute MULTIPLE_SELECTIONS. By default, this attribute is not enabled.

Users can make multiple selections by pressing the CTRL key while selecting a cell or range of cells with a single mouse click. All selections can be cleared by either a single click anywhere in the table or pressing the SHIFT key while clicking the mouse once anywhere in the table.

By default, the current selected group of cells are registered as a drag site. However, the drag operation is disabled when there is more than one selection.

Extended Selection

Extended selection refers to the ability to select or highlight a range of contiguous cells, extending a selection from the active cell (starting anchor point) to the cell last clicked with the mouse (ending anchor point).

Users can make an extended selection by pressing the SHIFT key while selecting a cell with a single mouse click. To clear all selections, single click anywhere in the table.

Extended selection is useful when the anchor points of your selected range are far apart. Instead of dragging out the entire selection you can select the cell that is the starting anchor point with a single click, scroll the table, then press the SHIFT key and hold it down while you select the cell that is the ending anchor point with a single click.

Row Selection Mode

Row selection mode expands a selection of any cell, except column labels, into a selection of the entire row that contains the selected cell. Row selection mode can be enabled with the table attribute SELECT_ROWS. By default, this attribute is not enabled.

When both the attributes SELECT_ROWS and MULTIPLE_SELECTIONS are set, table users can select multiple noncontiguous rows by pressing the CTRL key while selecting a row with a single mouse click. Users can deselect a row by pressing the CTRL key and clicking on the selected row.

Row selection mode is useful for mimicking list box behavior.

Column Selection Mode

Column selection mode expands a selection of any cell, except row labels, into a selection of the entire column that contains the selected cell. Column selection mode can be enabled with the table attribute SELECT_COLUMNS. By default, this attribute is not enabled.

When both the attributes SELECT_COLUMNS and MULTIPLE_SELECTIONS are set, table users can select multiple noncontiguous columns by pressing the CTRL key while selecting a column with a single mouse click. A column can be deselected by pressing the CTRL key and clicking on the selected column.

Label Selection Mode

Label selection mode expands the selection of any row or column label into a selection of the entire row or column, respectively. Label selection mode is enabled with the table attribute SELECT_LABELS. By default, this attribute is not enabled.

When both the attributes SELECT_LABELS and MULTIPLE_SELECTIONS are set, users can select multiple noncontiguous rows or columns in the table by pressing the CTRL key while selecting a row or column label, respectively, with a single mouse click.

Users can deselect a column or row by pressing the CTRL key and clicking on the selected element.

The SELECT_LABELS table attribute also has three companion table attributes, SELECT_ROW_LABELS, SELECT_COLUMN_LABELS, and SELECT_TITLES. The SELECT_LABELS attribute treats label selections as selections of the corresponding row or column. Alternatively, you can enable this behavior individually for row label cells with SELECT_ROW_LABELS, column label cells with SELECT_COLUMN_LABELS, or title cells with SELECT_TITLE_LABELS. Thus, the SELECT_LABELS table attribute is the equivalent of enabling all three of these companion table attributes. By default, none of these companion table attributes are enabled.


Coordinate Lists

All of the methods that operate on a particular row, column, or cell have coordinate arguments. These arguments are SCL lists rather than simple numerics in order to deal with multi-dimensional data, that is, nested rows or columns. Each element in one of these lists contains an integer value. Thus, the lists are simply integer arrays where each integer is a row-column coordinate for the table dimension that corresponds to that element's index number.


Units of Measure

Several of the methods accept a unit of measure argument. The following table lists the valid units and provides a definition:

Name Description
in inches
cm centimeters
mm millimeters
pt points
pc picas
el l-space (one-third the width of an em)
em the width of a piece of type about as wide as it is tall; usually 1 ln in the x-direction
en n-space (half the width of an em)
ex x-space (height of the x-character)
fg figure width (width of the zero-character)
sp space (width of the space-character)
cc width of the widest character in the font
ht height of the tallest character in the font
dp depth of the deepest character in the font
ln line space (1ht+1dp)


Creating a Multi-dimensional Model Class for Use with the Table Editor

The Table Editor has the ability to display data from a model in a simple table or in a complex or multi-dimensional table. A model representing a rectangular data source such as a SAS dataset (for example, Data Set Data Model) will produce a simple table while a model representing a hierarchical data source (for example, Multi-dimensional Data Base Model) can yield a complex or multi-dimensional table. In either case, it is up to the data model to convey the structure of it's data source as well as the data itself to the Table Editor.

Communication between the Table Editor and it's Model

Any class that provides the methods defined by Table Data Model can be used as a model for the Table Editor. The Table Data Model defines the methods that are required to communicates between the model and the Table Editor. The following are the methods that are called by the Table Editor on the model. These methods can be divided into two sections: request methods, which provide the Table Editor with information about the model's data source and notification methods, which provide the model with information about the Table Editor.

The request methods can be further divided into two categories. The first category of method provides information about data structure of the model's data source using the _getColumnDimInfo, _getRowDimInfo, and _getTitleDimInfo methods. The second category of methods provides the actual data content from the model's data source using the _getColumnInfo, _getRowInfo, _getTitleInfo, and _getData methods.

The Table Editor calls the methods that provide the data structure when the model is first attached to the Table Editor and then afterwards only if requested by the model. When the model's data structure changes, the model can inform the Table Editor by calling one of the following methods: _updateColumnDim, _updateRowDim, _updateTitleDim and _updateDim. This will cause the Table Editor to re-query the data structure from the model.

The Table Editor calls the methods that provide the model's data content whenever the current view changes. Circumstances that cause the view to change include scrolling and resizing the table, font and margin changes, and explicit update requests from the model by calling the one of the following methods of the Table Editor: _update, _updateColumnData, _updateColumnLabels, _updateData, _updateLabels, _updateRange, _updateRowData, _updateRowLabels, _updateTitleLabels.

Structure of the Columns and Rows

This example will show you how to create a multi-dimensional model that can be used with the table editor. Note, when using this model, you cannot move rows and columns within the Table Editor. The model created will be a subclass of Table Data Model class and assumes that the data used will be available in an SCL List form containing a hierarchy of lists. This list will be stored as an instance variable on the model named 'DATABASE', which the multi-dimensional model will use to retrieve the information about the row and columns data structure and contents.

In this example, the data being modeled has 3 top-level columns labeled 'CANADA', 'GERMANY' and 'USA'. In the second-level of the hierarchy, each of the top-level columns has 2 second-level columns labeled 'CONSUMER' and 'EDUCATION'. In the third-level of the hierarchy, each of the second-level columns, 'CONSUMER' and 'EDUCATION', has a third-level column labeled 'ACTUAL'.

There are 2 top-level rows labeled '1998' and '1999'. Each top-level row has 4 second-levels row labeled 'Quarter 1' through 'Quarter 4'. Within each second-level row, there is a numeric data value for each third-level column.

In the example below, the sublist 'COLUMNS' and the rows are stored in order within a sublist 'ROWS'.

DATABASE(COLUMNS=(CANADA=(CONSUMER=('ACTUAL'
                                     )[L]
                          EDUCATION=('ACTUAL'
                                     )[L]
                          )[L]
                  GERMANY=(CONSUMER=('ACTUAL'
                                     )[L]
                           EDUCATION=('ACTUAL'
                                      )[L]
                           )[L]
                  USA=(CONSUMER=('ACTUAL'
                                 )[L]
                       EDUCATION=('ACTUAL'
                                  )[L]
                       )[L]
                  )[L]
         ROWS=(1998=(QUARTER 1=(16197
                                15103
                                15114
                                15076
                                14515
                                13758
                                )[L]
                     QUARTER 2=(14547
                                20027
                                14114
                                14898
                                13741
                                16032
                                )[L]
                     QUARTER 3=(14870
                                14983
                                15452
                                13052
                                13800
                                16892
                                )[L]
                     QUARTER 4=(15222
                                15252
                                13181
                                15200
                                16793
                                15954
                                )[L]
                     )[L]
               1999=(QUARTER 1=(13238
                                15766
                                15383
                                14925
                                15020
                                14938
                                )[L]
                     QUARTER 2=(12928
                                17887
                                16401
                                18479
                                15978
                                14130
                                )[L]
                     QUARTER 3=(15255
                                15791
                                16069
                                16564
                                14851
                                14904
                                )[L]
                     QUARTER 4=(14804
                                15351
                                16229
                                13354
                                17601
                                13631
                                )[L]
                     )[L]
               )[L]
         )[L]

Creating the DATABASE SCL List

The following is the code needed to create the SCL list DATABASE that will be used in this example. This code can be used one of two ways:

  1. Include the code into the INIT label of the FRAME entry containing the Table Editor. This means that the SCL List DATABASE will be created each time the FRAME is executed.

  2. Include the code into a separate SCL entry to create the list and then save the list as an SLIST entry. This SLIST entry can then be read within the INIT label of the FRAME entry containing the Table Editor.

 Note about code
init:
   rootlst = makelist();
 Note about code
   columns = makelist();
   rc = setniteml(rootlst, columns,
                  'COLUMNS' );

      /* Create CANADA sublist for the */
      /* first column */
   canada = makelist();
   rc = setniteml(columns, canada,
                  'CANADA' );
   consumer = makelist();
   rc = setniteml(canada, consumer,
                  'CONSUMER' );
   rc = setitemc(consumer, 'ACTUAL',
                  1, 'y' );
   education = makelist ();
   rc = setniteml( canada, education, 
                  'EDUCATION' );
   rc = setitemc (education, 'ACTUAL',
                  1, 'y');

      /* Create GERMANY sublist for the */
      /* second column */
   germany = makelist();
   rc = setniteml( columns, germany,
                   'GERMANY' );
   consumer = makelist();
   rc = setniteml( germany, consumer,
                  'CONSUMER' );
   rc = setitemc( consumer, 'ACTUAL',
                  1, 'y' );
   education = makelist();
   rc = setniteml( germany, education,
                   'EDUCATION' );
   rc = setitemc( education, 'ACTUAL',
                  1, 'y' );


      /* Create USA sublist for the */
      /* third column */
   usa = makelist();
   rc = setniteml( columns, usa,'USA' );
   consumer = makelist();
   rc = setniteml( usa, consumer, 
                  'CONSUMER' );
   rc = setitemc( consumer, 'ACTUAL', 
                  1, 'y' );
   education = makelist();
   rc = setniteml( usa, education, 
                   'EDUCATION' );
   rc = setitemc( education, 'ACTUAL', 
                  1, 'y' );
 Note about code
   rows = makelist();
   rc = setniteml( rootlst, rows, 'ROWS' );
 Note about code
   year = makelist();
   rc = setniteml(rows, year, '1998');
   qtr = makelist();
   rc = setniteml(year, qtr, 'Quarter 1');
   rc = setitemn(qtr, 16197, 1, 'y');
   rc = setitemn(qtr, 15103, 2, 'y');
   rc = setitemn(qtr, 15114, 3, 'y');
   rc = setitemn(qtr, 15076, 4, 'y');
   rc = setitemn(qtr, 14515, 5, 'y');
   rc = setitemn(qtr, 13758, 6, 'y');
   qtr = makelist();
   rc = setniteml(year, qtr, 'Quarter 2');
   rc = setitemn(qtr, 14547, 1, 'y');
   rc = setitemn(qtr, 20027, 2, 'y');
   rc = setitemn(qtr, 14114, 3, 'y');
   rc = setitemn(qtr, 14898, 4, 'y');
   rc = setitemn(qtr, 13741, 5, 'y');
   rc = setitemn(qtr, 16032, 6, 'y');
   qtr = makelist();
   rc = setniteml (year, qtr, 'Quarter 3');
   rc = setitemn(qtr, 14870, 1, 'y');
   rc = setitemn(qtr, 14983, 2, 'y');
   rc = setitemn(qtr, 15452, 3, 'y');
   rc = setitemn(qtr, 13052, 4, 'y');
   rc = setitemn(qtr, 13800, 5, 'y');
   rc = setitemn(qtr, 16892, 6, 'y');
   qtr = makelist();
   rc = setniteml(year, qtr, 'Quarter 4');
   rc = setitemn(qtr, 15222, 1, 'y');
   rc = setitemn(qtr, 15252, 2, 'y');
   rc = setitemn(qtr, 13181, 3, 'y');
   rc = setitemn(qtr, 15200, 4, 'y');
   rc = setitemn(qtr, 16793, 5, 'y');
   rc = setitemn(qtr, 15954, 6, 'y');
 Note about code
   year = makelist();
   rc = setniteml(rows, year, '1999');
   qtr = makelist();
   rc = setniteml(year, qtr, 'Quarter 1');
   rc = setitemn(qtr, 13238, 1, 'y');
   rc = setitemn(qtr, 15766, 2, 'y');
   rc = setitemn(qtr, 15383, 3, 'y');
   rc = setitemn(qtr, 14925, 4, 'y');
   rc = setitemn(qtr, 15020, 5, 'y');
   rc = setitemn(qtr, 14938, 6, 'y');
   qtr = makelist();
   rc = setniteml(year, qtr, 'Quarter 2');
   rc = setitemn(qtr, 12928, 1, 'y');
   rc = setitemn(qtr, 17887, 2, 'y');
   rc = setitemn(qtr, 16401, 3, 'y');
   rc = setitemn(qtr, 18479, 4, 'y');
   rc = setitemn(qtr, 15978, 5, 'y');
   rc = setitemn(qtr, 14130, 6, 'y');
   qtr = makelist();
   rc = setniteml(year, qtr, 'Quarter 3');
   rc = setitemn(qtr, 15255, 1, 'y');
   rc = setitemn(qtr, 15791, 2, 'y');
   rc = setitemn(qtr, 16069, 3, 'y');
   rc = setitemn(qtr, 16564, 4, 'y');
   rc = setitemn(qtr, 14851, 5, 'y');
   rc = setitemn(qtr, 14904, 6, 'y');
   qtr = makelist();
   rc = setniteml(year, qtr, 'Quarter 4');
   rc = setitemn(qtr, 14804, 1, 'y');
   rc = setitemn(qtr, 15351, 2, 'y');
   rc = setitemn(qtr, 16229, 3, 'y');
   rc = setitemn(qtr, 13354, 4, 'y');
   rc = setitemn(qtr, 17601, 5, 'y');
   rc = setitemn(qtr, 13631, 6, 'y');
 Note about code
   rc = savelist( 'CATALOG', 
                  'MYLIB.MYCAT.DATABASE.SLIST',
                   rootlst );
 Note about code
   rc = dellist( rootlst, 'Y' );
return;

Creating the Multi-Dimensional Model Subclass to Read the DATABASE list

Now that the DATABASE list has been created, you need to create the multi-dimensional model subclass that will read the DATABASE list. To create a subclass of the Table Data Model and use this new class with a FRAME that contains a Table Editor object, follow these steps:

  1. Subclass the Table Data Model class.
    1. Edit multidim.class.

    2. Set the description to 'My Multidimensional Class' and the parent class to 'SASHELP.FSP.TABLE_M.CLASS'.

    3. Select 'Methods' under 'Additional Attributes' and override the following methods:

      • _getColumnDimInfo method using the label of GETCDIM.

      • _getColumnInfo method using the label of GETCOL.

      • _getRowDimInfo method using the label of GETRDIM.

      • _getRowInfo method using the label of GETROW.

      • _getData method using the label of GETDATA.

    4. Edit the SCL entry NEWTBLM.SCL using the source from 'Overriding Table Model methods for a multi-dim model' below.

    5. Compile and save the SCL entry.

  2. Create a Table Editor object in a FRAME.
    1. Edit new.frame.

    2. Create an empty region in the FRAME entry.

    3. Use the command RM FILL 'TABLE EDITOR'.

    4. In the Table Editor Attribute Window set the name to 'Table' and OK from the window.

    5. Edit the FRAME's SCL and use the source from 'Multidimensional Frame SCL'.

    6. Compile and save the FRAME.

    7. TESTAF the FRAME.


Overriding Table Data Model Methods for a Multi-dimensional Model

The following code overrides the methods from the Table Data Model for a multi-dimensional model.
 Note about code
length _method_ $ 50;

_self_ = _self_;
 Note about code
   /*  This is a method override for the _getColumnDimInfo method
    *    of the Table Data Model, which provides the table editor with
    *    the column dimension hierarchy information.  Parameters passed
    *    to this method:
    *        'level'    - specifies the address of the column dimension being
    *                     requested.
    *        'num_cols' - returns the number of columns that are present
    *                     at the requested dimension.
    *        'sub_cols' - returns whether the requested dimension has any
    *                     subdimensions.
    *        'height'   - not used in this example.
    *        'units'    - not used in this example.
    *        'groups'   - not used in this example.
    *        'eod'      - not used in this example. */
GETCDIM: method level num_cols sub_cols height 8 units $ 4 groups 8 eod $ 1;
      /* Determine which column level is being requested and indicate
       *   (1)  How many columns (num_cols) the table has for this dimension.
       *   (2)  Whether this dimension has any subdimensions (sub_cols).
       *  At the top level dimension, there are 3 columns and each has
       *     subdimensions. */
   len = listlen( level );
   if ( ^len ) then
   do;
      num_cols = 3;
      sub_cols = 1;
   end;
      /*  At the second level dimension, there are 2 columns and each has
       *    subdimensions. */
   else if ( len = 1 ) then
   do;
      num_cols = 2;
      sub_cols = 1;
   end;
      /*  At a third level dimension, there is 1 column and with no
       *    subdimensions. */
   else
   do;
      num_cols = 1;
      sub_cols = 0;
   end;
endmethod;
 Note about code
   /*  This is a method override for the _getRowDimInfo method
    *    of the Table Data Model, which provides the table editor with
    *    the row dimension hierarchy information.  Parameters passed
    *    to this method:
    *        'level'    - specifies the address of the row dimension being
    *                     requested.
    *        'num_rows' - returns the number of rows that are present at
    *                     the requested dimension.
    *        'sub_rows' - returns whether the requested dimension has any
    *                     subdimensions.
    *        'height'   - not used in this example.
    *        'units'    - not used in this example.
    *        'groups'   - not used in this example.
    *        'eod'      - not used in this example. */
GETRDIM: method level num_rows sub_rows width 8 units $ 4 groups 8 eod $ 1;

      /*  Determine the row level being requested and indicate:
       *     (1) How many rows (num_rows) the table has in this
       *         dimension.
       *     (2) Whether this dimension has subdimensions (sub_rows) */
   len = listlen (level);
      /*  At the top level dimension, there are 2 rows and each row
       *     has subdimensions. */
   if ( ^len ) then
   do;
      num_rows = 2;
      sub_rows = 1;
   end;
      /*  At the second-level dimension, there are 4 rows and with no
       *     subdimensions. */
   else
   do;
      num_rows = 4;
      sub_rows = 0;
   end;
endmethod;
 Note about code
   /*  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;
 Note about code
   /*  This is a method override for the _getRowInfo method
    *    of the Table Data Model, which provides the table editor with
    *    the information about the row labels. Parameters passed to this method:
    *        'rcdvecid'  - Use instance of the Row/Column data vector.
    *                      The information about the requested row is
    *                      set on the data vector. */
GETROW: 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 ROWS sublist which
       *    contains the information about the rows.  Within the ROWS
       *    list, the rows are stored in order starting at the beginning
       *    of the list.  For example, the first row, 1998, in the
       *    ROWS list is the first row to display in the table editor. */
   database = getniteml( _self_, 'DATABASE' );
   rowlst = getniteml( database, 'ROWS' );

      /*  Use the _getCoordinates method of the Row/Column Data Vector
       *     to retrieve which row is currently being requested by the
       *     table editor for display. */
   coords = makelist();
   call send ( rcdvecid, '_getCoordinates', coords );

      /* Get the first row dimension off of the COORDS list */
   rownum = getitemn( coords, 1 );

      /*  Retrieve the other row subdimension if available on the
       *     COORDS list. */
   if ( listlen( coords ) = 1 ) then
      subrownum = 0;
   else
      subrownum = getitemn( coords, 2 );

      /* The COORDS list is no longer needed. Delete the COORDS list. */
   coords = dellist( coords );

      /*  Determine the label for the row to be displayed. */
      /* If Table Editor has requested two dimensions... */
   if ( subrownum ) then
   do;
         /*  Using the top-level row dimension(ROWNUM), retrieve the
          *     top-level dimension list from ROWS.  For example, if
          *     ROWNUM is 1, then the sublist 1998 would be retrieved
          *     from the ROWS list. */
      rowlst = getiteml( rowlst, rownum );

         /*  Since the last requested level is the second-level dimension,
          *     you need retrieve the row label by getting the
          *     name of the SUBROWNUM item from the top-level list. */
      label = nameitem( rowlst, subrownum );
   end;
      /* If Table Editor has requested one dimension... */
   else
         /*  Since the last requested level is the top-level dimension,
          *     you need retrieve the row label by getting the
          *     name of the ROWNUM item from the ROWS list. */
      label = nameitem( rowlst, rownum );

      /* Set the label on the Row/Column Data Vector for the row. */
   call send( rcdvecid, '_setText', label );
endmethod;
 Note about code
   /*  This is a method override for the _getData method of the Table
    *    Data Model, which provides the table editor with contents of the
    *    data to be displayed. Parameters passed to this method:
    *        'gddvecid'  - Use instance of the GET_DATA data vector class.
    *                      The data vector is filled in with the contents
    *                      of the requested row.
    *                      data vector for 'num_cols'.
    *        'num_cols'  - The number of columns to retrieve from the
    *                      requested row. */
GETDATA: method gddvecid num_cols 8;

      /*  Retrieve the value of the instance variable DATABASE
       *    which contains the information for this multi-dimensional example.
       *    From the DATABASE list, retrieve the ROWS sublist which
       *    contains the information about the rows.  Within the ROWS
       *    list, the rows are stored in order starting at the beginning
       *    of the list.  For example, the first row, 1998, in the
       *    ROWS list is the first row to display in the table editor.*/
   database = getniteml( _self_, 'DATABASE' );
   rowlst = getniteml( database, 'ROWS' );

      /*  Use the _getRow method of the GET_DATA Data Vector to retrieve
       *     which row is currently being requested by the table editor for
       *     display. */
    coords = makelist();
    call send( gddvecid, '_getRow', coords );

      /* Get the top-level row dimension from the COORDS list */
   rownum = getitemn( coords, 1 );

      /* Get the second-level row dimension from the COORDS list */
   subrownum = getitemn( coords, 2 );

      /* The COORDS list is no longer needed. Delete the COORDS list. */
   coords = dellist( coords );

      /*  Using the top-level row dimension(ROWNUM), retrieve the
       *     top-level dimension list from ROWS.  Then using the
       *     second-level row dimension(SUBROWNUM), get the second-level
       *     list from the top-level list.  For example, if
       *     ROWNUM is 1, then the sublist 1998 would be retrieved
       *     from the ROWS list.  If SUBROWNUM is 3, then the sublist
       *     'Quarter 3' would be retrieved. */
   rowlst = getiteml( rowlst, rownum );
   rowlst = getiteml( rowlst, subrownum );

      /*  From the second-level list retrieve the value for each of the
       *    passed columns.  For each requested column:
       *       (1)  Get the column coordinates
       *       (2)  Get the column text
       *       (3)  Set the text in gddvecid */
   colcoords = makelist();
   do i = 1 to num_cols;

         /*  Each time through the loop, we need to set the index for the
          *    the current column in gddvecid.  Then get the column
          *    coordinates for that column. */
      call send( gddvecid, '_setIndex', i );
      call send( gddvecid, '_getColumn', colcoords );

         /*  Get the top-level and second-level column dimensions from the
          *    COLCOORDS list. */
      colnum = getitemn( colcoords, 1 );
      subcolnum = getitemn( colcoords, 2 );

         /* Calculate where to retrieve the data */
      colnum = colnum * 2 - mod( subcolnum, 2 );

         /* Retrieve the data and convert it to a character string. */
      text = trim(left(put(getitemn(rowlst, colnum), 12. )));

         /* Set the data in gddvecid */
      call send ( gddvecid, '_setText', text );
   end;

      /* The COLCOORDS list is no longer needed. Delete the COLCOORDS list. */
   colcoords = dellist( colcoords );
endmethod;

Multi-dimensional Frame SCL

The frame's SCL for the Multi-dimensional example is shown here.
 Note about code
rc = rc;
init:
   classid = loadclass
             ("MYLIB.MYCAT.MULTIDIM.CLASS");
   call send( classid, "_new",  modelid );
 Note about code
   database = makelist();
   rc = fillist( 'catalog', 
                 'MYLIB.MYCAT.DATABASE.SLIST', 
                 database );
   rc = setniteml( modelid, database, 
                  "DATABASE" );
 Note about code
   call notify( 'table', '_attach', modelid );
return;
 Note about code
term:
   call notify( 'table', '_detach' );
   call send( modelid, '_term' );
 Note about code
   database = dellist( database );
return;


Chapter Contents

Previous

Next

Top of Page

Copyright 1999 by SAS Institute Inc., Cary, NC, USA. All rights reserved.