Legend:
Library
Module
Module type
Parameter
Class
Class type
Tables with sortable columns and selectable rows.
This module helps you create multi-column tables. You just need to provide the contents of each row.
Click on the column title to sort the table with respect to this column.
Click on a row to select or unselect it.
After clicking on a row, hit CTRL-A to select all rows at once.
After clicking a row, click on another row with SHIFT pressed to select a range of rows.
One can limit the maximum number of selected rows.
Actions can be executed when a row is clicked on.
Tables internally use a Long_list and hence will nicely handle a very large number of rows. A vertical scrollbar will appear as soon as the whole table height does not fit in the layout. However, contrary to Long_lists, in a table all rows must have the same height.
A three-column table (plus two buttons)
(Example #35)
row i should return the Layout corresponding to the ieth entry of that column.
*)
compare : (int ->int -> int) option;
(*
if a compare function is provided, then the column will be dynamically sortable by the user. compare i1 i2 > 0 means that entry i1 is larger than entry i2.
*)
min_width : int option;
(*
pixel width of the column. If not specified, the max width of the first 50 entries will be used.
Create a table by specifying its list of columns; in each column, the entries can be arbitrary layouts. If entries are simple text labels, it's easier to use the helper functions of_array or of_list. If row_height is not specified, the height of the first row is used instead. The width of the table is determined by the min_width column parameters.
Some rows can be initially selected by providing the selection argument.
The function on_select is executed each time the selection is modified. Its argument is the new selection. This function is executed before the new selection is recorded in the table variable (of type t).
Everytime a row is clicked, the on_click function is called with two arguments: the table itself and the index of the row. (The first row has index 0. )