# Table Widget¶

The Table widget allows you to visualize and/or edit the data of one or more AIMMS identifiers represented in a tabular format:

The table widget offers the user possibilities for various actions such as:

• Sort table data by using the sort buttons as illustrated in the picture below:

The sort button applies one of the 3 states: increasing, decreasing, default:

For example, if one chooses for the “increasing” sorting in the example above, the rows of the table are sorted as follows:

• change several Widget Options, e.g.

• customize the table by drag-and-drop of the indices (Pivot),
• specifying reverse links on the ‘Store focus’ tab of the widget’s option editor. When a cell has the focus in the table, the element parameter(s) that you specify here will be filled accordingly. Such element parameters may be used at the same time by other widgets, which will update automatically. Hence, the ‘Store focus’ functionality opens up various possibilities for interaction between the widgets.
• specify various identifier settings; in particular, specifying display domain, slicing, or expanding indexes
• Save the table data to a .csv file by using the Download Table Data functionality, see below.

• Change the column widths of the table, simply by dragging them to where you want them.

• Change the default row height of the table, by specifying a positive integer value in the ‘Default row height’ option in the Miscellaneous options editor.

• Use your keyboard (as well as the mouse) to navigate the table.

• You can use the 0 or the 1 key to set binary values displayed as checkboxes that have the focus.
• You can use the space bar to toggle binary values displayed as checkboxes that have the focus.
• You can use either ENTER or ALT+ARROW DOWN to open the drop-down list in focus, in order to change its value.

The Table Widget offers you the possibility to download its current contents to a .csv file on your local machine, which you can use to further process your data in, for example, Excel. On the top right, left of the ‘Full Screen’ icon, you can find the download icon.

When you click it, the contents of the table, exactly as you configured it (in terms of pivoting, for example), will be downloaded to a .csv file. Depending on your browser, you can specify the name of the file or the download location. As a default, the name of your table will be used as the filename with the ‘.csv’ extension.

If your table contains numerical data, the numbers will be written to the .csv file in their maximum precision. So, if you display only 2 decimals in the table, but the underlying number is for example 1.2345, the full precision is written to the file. This allows you to do calculations in Excel with the resulting file, without running into rounding errors. Furthermore, the value ‘na’ from AIMMS is written as the value ‘#N/A’, which is used in Excel, in order to maximize the compatibility.

Furthermore, there is a limit on the number of rows that can be downloaded (i.e. even when having just 1 column!): this is controlled by the value of the project option WebUI_maximum_number_of_entries_in_widget. The default value of this option is currently 1,000,000.

### By using flags (in runtime)¶

In a Table widget, it is possible to make specific cells read-only for the user. You can do this by using an extra string parameter in your model, which has the same name and index domain as the identifier which defines the content of the table, only post-fixed with _flags. So, if you have a Table widget showing the content of parameter MyTableData(i, j), you should add a string parameter called MyTableData_flags(i, j) in your model. In order to actually make some cells read-only, you have to set the value of the right index combination(s) to "readonly". So, in our example, you should add a line like:

MyTableData_flags(i, 'some_value_for_j') := "readonly";


After doing so, the affected cells in your Table widget will be displayed (in the default WebUI theme) in black, indicating that they cannot be edited. All the other cells are in the default (blue) color.

In case you want to change a cell to become editable again, you have to assign the empty string to the corresponding flags-identifier. So, to undo the effect of the above statement, you should execute the following code:

MyTableData_flags(i, 'some_value_for_j') := "";


### By using the CurrentInputs set (in runtime)¶

Another way to influence the modifiability of cells, is to use the CurrentInputs set of AIMMS. This set is a predeclared subset of AllIdentifiers. The identifiers referenced in it are modifiable sets and parameters in both the WinUI and the WebUI. Consider a parameter P. Without further specification, this parameter is a parameter that can be modified both in the WinUI and in the WebUI. By removing this element 'P' from CurrentInputs, the parameter P will no longer be modifiable in either the WinUI or the WebUI.

CurrentInputs := CurrentInputs - 'MyTableData';


### By using the WebUI authorization (not in runtime)¶

You may use the Authorization support from the WebUI Library described in Creating a WebUI. Please mind this authorization is not updated at WebUI runtime. Thus, the following code should be part of the PostMainInitialization predeclared procedure or the Startup Procedure ( Settings===>Project Options===> Startup & authorization ).

! Turns MyTableData identifier read-only
webui::IdentifierAuthorization('MyTableData') := 4;


Authorization Schema reminder:

Identifier Authorization Value Description
no access 0 No data will be shown in the WebUI, even if the identifier is specified in a widget in the WebUI. Procedures will not be executed
read access 4 Data will be displayed in the WebUI, but will be shown as read-only data. Data changes via the WebUI are prohibited. Procedures will not be executed.
read and execute access 5 Data will be displayed in the WebUI, but will be shown as read-only data. Data changes via the WebUI are prohibited. Procedures with this permission can be executed from within the WebUI.
read and write access 6 Data will be displayed in the WebUI, and are displayed as editable if no other restrictions prohibit editing the data (e.g. defined identifiers). Data changes via the WebUI are not prohibited. Procedures will not be executed.
full access 7 Data will be displayed in the WebUI, and are displayed as editable if no other restrictions prohibit editing the data (e.g. defined identifiers). Procedures with this permission can be executed from within the WebUI.

Last Updated: December, 2019