Keying on Items Within Tables

From HLKitWiki
Jump to: navigation, search

Context: HL KitBasic Concepts and Terminology … Manipulation of Visual Elements … Working With Tables 

When working with tables, there will be times where you will want to base sizing and positioning on the number of items within a particular table. This will most often occur when trying to intelligently fit multiple tables into a limited amount of space.

The Kit provides two important mechanisms for determining the items in a table. First, there is the "itemcount" target reference that returns the total number of items within the table. Second, there is the "itemsshown" target reference that returns the number of items that are actually visible within the table.

The utility of the item count is probably obvious. By checking the item count, you can determine that a particular table contains no visible items. When generating printed output, a table with no visible items should generally be completely omitted. To achieve this, you can easily check the number of items in a table and set its visibility to zero if the count is zero.

The number of items shown is equally useful. By comparing the number of items shown to another value, you can make appropriate determinations about the what's going on with the table. Most commonly, you will compare the number of items shown against the total number of items in the table. If the values are the same, then you know that the entire contents of the table are visible. When generating printed output, if the two values do not match, then you know that one or more items were not included in the table. This makes it possible to intelligently determine how to lay out the page, since you can quickly determine whether information is omitted and/or will be appearing in a subsequent spillover section of the printout.