![]() Chapter Contents |
![]() Previous |
![]() Next |
| SAS/AF Software: Class Dictionary |
| 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:
sashelp.fsp.table_e.class entry.
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 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 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 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 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 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.
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.
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]
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:
| | init: rootlst = makelist(); |
| | rows = makelist(); rc = setniteml( rootlst, rows, 'ROWS' ); |
| |
rc = savelist( 'CATALOG',
'MYLIB.MYCAT.DATABASE.SLIST',
rootlst ); |
| | rc = dellist( rootlst, 'Y' ); return; |
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:
The following code overrides the methods from the Table Data Model for a multi-dimensional model.
| | length _method_ $ 50; _self_ = _self_; |
The frame's SCL for the Multi-dimensional example is shown here.
| |
rc = rc;
init:
classid = loadclass
("MYLIB.MYCAT.MULTIDIM.CLASS");
call send( classid, "_new", modelid ); |
| |
database = makelist();
rc = fillist( 'catalog',
'MYLIB.MYCAT.DATABASE.SLIST',
database );
rc = setniteml( modelid, database,
"DATABASE" ); |
| | call notify( 'table', '_attach', modelid ); return; |
| | term: call notify( 'table', '_detach' ); call send( modelid, '_term' ); |
| | database = dellist( database ); return; |
![]() Chapter Contents |
![]() Previous |
![]() Next |
![]() Top of Page |
Copyright 1999 by SAS Institute Inc., Cary, NC, USA. All rights reserved.