Tables are defined with rows, columns, and options. It is possible to have the same granular control of the ordering of all three of those axes as exists for regular lists and questions.
The order
, flatorder
, and orderfrom
tags in a table will affect table options, as defined locally or through an optsfrom
tag. Rows and columns can be likewise manipulated with the rows/cols version of the same tag.
Tip! For simple randomization of options, Survey Programmers (SPs) should use randomize: y
instead of order: [*]
.
Tags
Tag |
Description |
---|---|
order |
Specifies option ordering; can be used within a table on options, rows, and columns if inline or on a list. |
roworder |
Specifies particular ordering patterns for randomizing the display of rows defined with the rowsfrom tag on a table. |
optorder |
Specifies particular ordering patterns for randomizing the display of options defined with the optsfrom tag on a table. |
colorder |
Specifies particular ordering patterns to randomize the display of columns defined with the colsfrom tag on a multicolumn table. |
flatorder |
Overwrites an existing list order for table options if a random order was previously defined. |
flatroworder |
Overwrites an existing list order for table rows if a random order was previously defined. |
flatcolorder |
Overwrites an existing list order for table columns if a random order was previously defined. |
roworderfrom |
Uses the order from another list or question to randomize the display of rows defined with the rowsfrom tag on a table. |
colorderfrom |
Uses the order from another list or question to randomize the display of columns defined with the colsfrom tag on a multicolumn table. |
optorderfrom |
Uses the order from another list or question to randomize the display of options defined with the optsfrom tag on a table. |
Examples
order
The order
tag can be placed multiple times within the same table, but the placement of the tag will determine which elements are randomized. For example, the order
tag must be placed immediately after the rows
tag if rows are called inline, otherwise, it will affect the position of the options instead of the row elements. In the example below, both the options and the rows are randomized. Note the randomize
tag can be used interchangeably with the order
tag here.
Similarly, the order
tag can apply to columns if the order
tag is placed immediately after the cols
tag. In the example below, options, rows, and columns are all randomized inline.
roworder, colorder, and optorder
As mentioned above, if a table only uses the order
tag, there is a chance the table might order the options instead of the rows or columns (depending on what else is going on in the table). The roworder
and colorder
tags make clarify which elements need to be re-ordered. The next example shows the use of the colorder
, roworder
, and optorder
tags. Alternatively, the order
or randomize
tag could be placed locally on the lists themselves, or inline as shown above.
flatorder
The flatorder tag directly overwrites an existing list order for table options if a random order was previously defined. The most common use-case is to overwrite option ordering in a list built from multiple collections. The hierarchy of collections is "flattened," so each individual list element can be directly referenced.
In the same manner, flatorder
can apply an ordering scheme to options, rows, or columns within a table if they are built from multiple collections. Lists called via optsfrom
are manipulated via flatorder
, whereas lists called via colsfrom
can use flatcolorder
and rowsfrom
can use flatroworder
.
In the following example, the table rows come from two sources. The flatroworder
tag randomizes all options together so that the two collections are mixed. Option numbers must be unique across both lists for this tag to work (for example, the option ID "1" cannot exist in both lists).
Note: In the flatorder
tag, collection headers themselves occupy a place in the numerical sequence. This is a key difference between order
and flatorder
, the order
tag does not do this. Headers accompany their respective collections.
orderfrom
The orderfrom
tag enables ordering defined in another widget to apply to table options. To override an existing list order, use an order
tag on the widget calling the list. This can be done on any question widget to redefine the existing ordering from a list called via an optsfrom
tag. To override existing list orderings for lists called via rowsfrom
or colsfrom
tags, use roworder
and colorder
. The roworder/roworderfrom
and colorder/colorderfrom
tags must be on the table itself, while the order
and orderfrom
tags can either be on the table itself or used in the bracketed inline manner shown a few examples down.
The following example is a way to use the tag roworderfrom
. The roworderfrom
tag is using the positional order of T10's row elements and applying them to T11's row elements; for example, if a respondent sees 3,1,2 for the row element order in T10, T11's rows will also be displayed in order of 3,1,2.
Inline ordering from a list call
It is also possible to put ordering instructions on the same line as an optsfrom/rowsfrom/colsfrom
list call. To do this, simply put the order
tag and its input inside square brackets after the list name. For simple tables as below, either the order
or randomize
tag could be placed on the list itself.
Below, the order from TX6, which is given a randomized order string inline, will be overwritten and assigned a new randomized order string at TX7 with the inline bracketed order
tag on rowsfrom
.
Unlike the roworderfrom
and colorderfrom
tags, the orderfrom
tag is also accepted in a bracketed inline use as shown below. In this example, TX5 will use the same position of the options as in TX4 even though the lists called in are different between the questions.
Comments
0 comments
Please sign in to leave a comment.