J6/Grid/Data

From J Wiki
Jump to navigation Jump to search
J6/Grid | Data Options Types | Actions Events Methods | Class DerivedClass | Hierarchical MultiDimensional MultiLine Virtual | Examples

Data is given in CELLDATA. Related globals are CELLTYPE and CELLFMT.

CELLDATA must be given, the others are optional.

CELLDATA can be in one of four forms:

If a boxed list of columns, each column must have the same number of items, and can in turn be either a boxed list, or a numeric or character list or matrix.

If values in CELLDATA are all character strings, then no formatting is required and the display is exactly as given. If the text has rank > 1, or contains LF characters, it is shown in several lines, see MultiLine Cells

If some values are numeric, they are formatted before display. The formatting takes into account both CELLTYPE and CELLFMT.

CELLTYPE is numeric cell types, and can be a singleton, a list of values for each column, or a matrix of values.

A type of 0 is just the normal cell type, while other values specify control types such as 100 for a flat checkbox. For cell types other than 0, the corresponding entry in CELLDATA must correspond to the cell type. Thus for a checkbox, CELLDATA should be 0 or 1.

CELLFMT is the cell formats as for 8!:0, and can be a single format, a list of formats for each column either as a boxed list or a comma-separated list, or a boxed matrix of formats with an entry for each cell of CELLDATA.

When CELLFMT is given, then if the format applies to columns or the entire data set, then each entry in the column or entire data set is formatted to the same number of decimal places.

Where number of decimal places is not given, the maximum number of decimal places that will be shown is 6.

Columns of Numeric Matrices

A data column may contain a numeric matrix, as in the result of the directory 1!:0 foreign conjunction, where the second column is the timestamp. This can be formatted using the same specifications as above, except that the separator is semicolon, and:

w.d width, number of decimal places
xN space, optional N gives number of spaces
z zero fill

For example: 6.2;x1;z4 means width 6, 2 decimal places; 1 space; zero filled, width 4 integer. In this example, a value of 456.789 123.4 is then formatted as:

456.79 0123

Negative Values

Negative numbers are formatted with a leading minus sign, i.e. -123 and not _123 .

Custom Formats

If the built in formats are insufficient, then CELLDATA should already be formatted, and contain only character strings. In this case, it may be appropriate to provide event handlers for edit and change, to ensure that any changes are made correctly.