Choice menus and Checkboxes in an edit table


4.6  •  5.0  •  5.1  •  5.2  •  5.3  •  5.4  •  6.0  •  6.1  •  6.2  •  6.3  •  6.4  •  6.5

You can include a drop-down menu (pull-down menu) in any cell of an edit table to let end users select an option for each cell. Here is an example, in browse mode.

Chapter11 74.jpg

You use the Choice function in the edit table cells, similar to using Choice to specify a single menu for a variable:

  1. Create a variable X as an edit table, in the usual way, selecting Table from the expr menu above its definition.
  2. Create an index variable, e.g., k, containing the list of options you want to make available from the menu(s), usually as a list of numbers or a list of labels.
  3. In the edit table of X, in edit mode, enter Choice(k, 1, 0) into the first cell that you want to contain a menu. The second parameter 1 means that the first element of k is the default option. The third parameter 0 means that it does not show All as an option, normally what you want. Note: When you enter the cell definition, the choice control displays immediately. You may want to edit the textual expression to make a change, or to copy the textual expression for pasting into other cells. In edit mode you can toggle between the viewing the control and the textual expression using the expression/control selector. Note that the selector is not present in browse mode, or when no cells with controls are visible.
    Chapter11 75.jpg
  4. Copy and paste Choice(k, 1, 0) from the first cell to any others you want also to contain the menu. You can also use other indexes than k if you want to include menus with other options. Here is an example containing drop-down menus in some but not all cells, with Show Expressions selected.
    Chapter11 76.jpg
  5. Select X, then select Make Input from the Object menu to make an input node for it. Move the input node to a good location. You will usually want an input node so the selections can be changed when the table is viewed in browse mode.
The variable containing the edit table with menus should always have an input node — otherwise, you won’t be able to select from the menus or edit other cells in browse mode.


You can also insert checkbox controls into table cells using the same steps. Enter the expression Checkbox(0) or Checkbox(1) directly into a cell.

MultiChoice controls

MultiChoice controls can also be placed in the cells of a table. These would be used when you want the user to be able to select any subset of the values. When used in a table, the MultiChoice will return a reference to the list of selected values (i.e., a set), unlike when it is used outside of a table and returns a list. The reference prevents the list dimension from combining with the dimensions of the table or dimensions arising from other cells.

To place a MultiChoice in a cell, simply enter the expression MultiChoice(Option), where Option is the name of your index that contains the options to display.

Slider controls

new in Analytica 6.3

Slider controls can also be placed in the cells of a table. These can include either a single-value selector or an interval selection (or even the rarer multiple values selection). This is done by entering a call to Slider a the cell expression, with a specification of the domain (i.e., possible values or continuous range). The reference on Slider information about the options.

To insert a continuous slider with a domain from 0 to 1 and initial selection of 0.5 enter: Slider(0.5).

To insert a continuous slider with a domain from 10 to 100 and initial selection of 20 enter: Slider(20, domain:Continuous(10,100))

One quirk when using at interval or a multiple-value slider in an edit table cell is that it is best to return the selection in a reference. If you don't use a reference, the resulting list becomes an implicit dimension of the table (and since you can have only one implicit index, only one interval slider not returning a reference would be allowed in the same table. To create an interval slider that wraps its results in a reference, use:

Slider( 0.2, 0.5, returnRef:true)

For information on how to configure the visual styles, configure a slider to have a discrete domain, etc., see Slider.

See Also


You are not allowed to post comments.