Directly Accessing Table Elements
The Table control provides access to an internally created sheet, row, column, and cell object; that is, the
Using instances of these subclasses is equivalent to setting the accessMode property of the Table control, summarized in the following table.
JadeTableElement Subclass | Equivalent to the accessMode value for the Table class… |
---|---|
|
Table.AccessMode_Cell |
|
Table.AccessMode_Column |
|
Table.AccessMode_Row |
|
Table.AccessMode_Sheet |
For details, see the appropriate class in
To eliminate the overhead of creating an object for each cell, column, row, and sheet of the table, only one object of each type is created, which is essentially a proxy object that holds the last reference to the cell, column, row, or sheet that was last accessed.
Accessing a cell, column, row, or sheet sets a corresponding property in the Table class that you can then use to subsequently access that table element, as follows.
-
accessCell method sets the accessedCell property to the returned cell
-
accessColumn method sets accessedColumn property to the returned column
-
accessRow method sets accessedRow property to the returned row
-
accessSheet method sets accessedSheet property to the returned sheet
The following code fragments show examples of accessing the last table elements that were accessed.
table1.accessCell(2, 3).inputType := Table.InputType_TextBox; table1.accessedCell.foreColor := Red; table1.accessSheet(2).accessCell(1, 4).text := "Company"; table1.accessedCell.alignment := Table.Alignment_Right_Middle;
Storing a reference to a returned cell causes problems unless you take a copy of that cell, as shown in the following example in which both cell1 and cell2 refer to the same object, which is referencing cell(3, 4).
cell1 := table1.accessCell(2, 3); cell2 := table1.accessCell(3, 4); cell1.text := "abc";
In the following example, cell1 has been cloned and still refers to cell(2, 3).
cell1 := table1.accessCell(2, 3).cloneSelf(true); // the cloned cell must be deleted by your logic cell2 := table1.accessCell(3, 4); cell1.text := "abc";