Chapter Contents |
Previous |
Next |
SAS/AF Software: Class Dictionary |
Assigning Names to the Columns |
Each column has a set of attributes to control how the data are displayed. These attributes are titles, formats, background colors, and foreground colors. Before you can set these attributes using their corresponding methods, you must assign names to the columns using the _setColumnNames method.
You can assign names to columns in two ways.
For examples that use the _setColumnNames method, see Example 1: Setting SCL List Model Attributes.
For an example that uses the attributes window and edits the contents of a list, see Example 2: Using the SCL List Model Attributes Window.
Example 1: Setting SCL List Model Attributes |
The following example shows how to set column attributes using the SCL List Model class. This example uses a
list generated from the CATALOG class. The list is composed of a sublist containing six named items: LIBNAME, CATNAME, OBJNAME, OBJTYPE, OBJDESC, and MODIFIED.
Follow these steps to reproduce the example in this section:
In this example, the viewer is called VIEWER. The viewer that is created using this code will only have four columns with titles. The ENTRY column will be blue with white text. The list contains information about each catalog entry in SASHELP.FSP.
INIT: catclass = loadclass ( 'sashelp.fsp.catalog.class' ); catalog = instance( catclass ); call send( catalog, '_setup', 'SASHELP.FSP' ); |
datalist = makelist(); call send( catalog, '_getMembers', datalist ); |
call notify( '.', '_getWidget', 'VIEWER', view_id ); engclass = loadclass ( 'SASHELP.FSP.LIST_M.CLASS' ); model = instance( engclass ); |
call send( model, '_setDataList', datalist ); call send( view_id, '_attach', model ); |
Example 2: Using the SCL List Model Attributes Window |
The example in this section shows how to use the SCL List Model Attributes window to define columns that can be used in a form editor or table editor object. When using the Form Editor class with the SCL List Model, you have to define the columns that will be present at runtime so that the user will be able to create a custom layout.
During the process of creating a custom layout, the user probably will need to create one or more new widgets on the screen. To enable a new widget to display values from the SCL List Model, you have to link a column to that widget. In other words, to enable a new widget to display values from the SCL List Model, you must identify to the SCL List Model those columns that will be present at runtime.
To identify the runtime columns, use the SCL List Model Attributes window.
After you use the attributes window to identify
the runtime columns, then the Form Editor automatically will know about the columns, and the user can use then to link to widgets. The alternative to defining the columns at buildtime and linking the
widgets is to add SCL code to create the links at runtime before any of the widgets would display data from the model.
The following example is an SCL program for a FRAME entry that contains a form editor or table editor
object, named VIEWER, that will display the contents of an SCL list, DATALIST, containing 4 named sublists. When displayed in the viewer, each sublist represents a row, and the items in the sublists
represent the columns.
Here is the structure of the list:
datalist: ( 1 = ( ONE = 1 TWO = 2 THREE = 3 FOUR = 4 )[] 2 = ( ONE = 2 TWO = 4 THREE = 6 FOUR = 8 )[] 3 = ( ONE = 3 TWO = 6 THREE = 9 FOUR = 12 )[] 4 = ( ONE = 4 TWO = 8 THREE = 12 FOUR = 16 )[] )[]
Follow these steps to create the frame entry:
new.frame
RM FILL 'FORM EDITOR'
. The Form Editor Attribute window will appear.
RM FILL 'TABLE EDITOR'
. The Table Editor Attribute window will appear.
You can edit and update DATALIST by:
length name $ 5 subname $ 8; array sublist{4} 8 sub1-sub4; |
call notify('viewer','_set_data_list_', datalist); attrs=makelist(); |
insertc(attrs,'Y',-1,'EDIT'); call notify('viewer','_set_attributes_', attrs); return; |
TERM: call putlist(datalist,'Contents of list after updates',0); if datalist then datalist=dellist (datalist,'y'); if attrs then attrs=dellist(attrs); return; |
Example 3: Subclassing the SCL List Model |
You can subclass the SCL List Model class to set column attributes based on the data values. In the following
example, the SCL List Model class is subclassed so that the rows in the display will have different background colors, based on the object type of each catalog entry. This example uses a list
generated from the CATALOG class. The list is composed of a sublist containing six named items: LIBNAME, CATNAME, OBJNAME, OBJTYPE, OBJDESC, and MODIFIED.
First, create a subclass of the SCL List Model class as follows:
work.example.mylistm.class
.
sashelp.fsp.data_m.class
.
init
.
get_row
.
term
.
The following SCL code is the contents of MYLISTM.SCL.
TERM: method; colors = getniteml( _self_, 'COLORS' ); rc = dellist (colors); call super( _self_, '_term' ); endmethod; |
Next, create a frame entry with a table editor object (in this example called TABLE), and then use the following SCL code. The table shown will have four columns, but the rows will be colored based on the entry type. The list contains information about each catalog entry in SASHELP.FSP.
INIT: catclass = loadclass ('sashelp.fsp.catalog.class'); catalog = instance( catclass ); call send( catalog, '_setup', 'SASHELP.FSP' ); |
datalist = makelist(); call send( catalog, '_getMembers', datalist ); |
call notify( '.', '_getWidget', 'TABLE', tabid ); engclass = loadclass ('WORK.EXAMPLE.MYLISTM.CLASS'); model = instance( engclass ); |
call send( model, '_setDataList', datalist ); call send( tabid, '_attach', model ); |
attrs = makelist(); rc = setnitemc( attrs, 'N', 'DISPLAY_rowNAMES' ); rc = setnitemc( attrs, 'Y', 'RESIZE_COL' ); call send( tabid, '_setAttributes', attrs ); |
Chapter Contents |
Previous |
Next |
Top of Page |
Copyright 1999 by SAS Institute Inc., Cary, NC, USA. All rights reserved.