Please enable JavaScript to view this site.

Answer specifies and returns the identity of the selected row(s), and also passes back and forth updates to editable cell data.

In the simplest case (single-selection array mode, no editable cells, no drag/drop), answer is treated as in PCKLST, where it is a single numeric variable of any numeric type and is interpreted as the selected row number (first row is 1), e.g.

MAP1 ANSWER,B,4          ! selected row for single selection

For multiple selection mode using array or file input (but no editable cells or drag/drop) (see flags XTF_MSEL, XTF_EDITABLE, XTF_DRAGDROP), answer must be an unformatted variable mapped as follows:

MAP1 ANSWER

   MAP2 ANSARY(x),S,1    ! each item is "0" if not selected, else "1"

                         ! (x) must be at least as large as addcnt

 

To support both single and multiple selection modes with a single form of the parameter, you can add the following MAP statement for the single selection response:

MAP1 ANS,B,4,@ANSWER      ! selected row for single selection

You can still pass the unformatted ANSWER variable (rather than ANS), but XTREE will treat it as if a B,4 variable in single selection mode. In other words, in single selection mode, XTREE assumes that an unformatted answer parameter is overlaid by a four-byte binary.

Note that although the rows may be sorted on the screen, either by the user or by XTREE based on the XTR.COLUMNSORT parameter, this does not affect the order of the original data, to which the row numbers returned in answer remain relative. In other words, if answer=5 on calling XTREE, it will select the fifth row in the source data (array or file), which may or may not appear as the fifth row on the screen, and which may be sorted again by the user to yet another position. Similarly, the answer value(s) returned will not necessarily reflect the position(s) of the selected item(s) as displayed, rather their position in the source data (which remains unaffected by any sorting performed by XTREE). Also note that if answer=0, the default selection will be the first row, except in the case of the append operation, in which case it will be the first row appended. Any other answer values are always interpreted as relative to the combined data (original plus appended).

For more complicated situations (involving some combination of multiple selection, editable cells, and/or drag-and-drop), answer must an array dimensioned at least as large as the number of rows of data in the tree, and whose row elements are formatted into one or more fields which must be precisely mapped according to the following principles:

If drag-drop allowed, the first field of every row must be a 4 character string which will return the original row number (1-9999).
If multi-selection allowed, the next field of every row is the one-byte selection flag (as described above).
If there are editable checkboxes/radiobuttons, then the next N fields will be for each of the editable checkboxes/radiobuttons, according to the relative sequence in which they are defined in the coldef parameter. Note that for each checkbox/radiobutton column that supports individual cell colors, the column width (in the main array and in the answer array) will be 2; otherwise it should be 1. Also note that all checkbox/radiobutton columns are represented in the answer array prior to any other kinds of editable columns, regardless of the order in which the checkboxes/radiobuttons and editable columns were defined.
Finally, for every editable column, there must be a corresponding field in each row of the answer array, whose size matches the defined size of the column. As with checkboxes and radio buttons, if the editable column supports individual cell colors, the width of the column in the answer array must be expanded by one to make room for the cell color byte at the start of the cell. And as before, the order of these editable columns in the answer layout must match the relative order in which they are defined in coldef (as opposed to the order in which they appear in the raw data).

See Also

Created with Help+Manual 9 and styled with Premium Pack Version 5 © by EC Software