du.widgets.grid

Module implementing a smart grid to store widgets.

Requires: d3@v4 du.widget

Grid

du.widgets.grid.Grid(name[, parent])

The grid class.
argtypedescription
namestringIdentifier of the widget.
parentobjectParent element to append widget to. If not specified, widget is appended to body. optional

x

du.widgets.grid.Grid.x(x[, dim])

Sets the X position of the widget.
Overrides: du.widget.Widget.x
argtypedescription
xnumberDistance from the window side. If positive, position is measured from the left, otherwise it is measured from the right.
dimstringDistance dimension. If not specified, pixels are used. optional
returndescription
du.widgets.grid.GridReference to the current Grid.

y

du.widgets.grid.Grid.y(y[, dim])

Sets the Y position of the widget.
Overrides: du.widget.Widget.y
argtypedescription
ynumberDistance from the window side. If positive, position is measured from the top, otherwise it is measured from the bottom.
dimstringDistance dimension. If not specified, pixels are used. optional
returndescription
du.widgets.grid.GridReference to the current Grid.

rows

du.widgets.grid.Grid.rows(size)

Sets the number of rows. Setting rows removes all contained widgets. Default is 1.
argtypedescription
sizenumberNumber of rows.
returndescription
du.widgets.grid.GridReference to the current Grid.

cols

du.widgets.grid.Grid.cols(size)

Sets the number of columns. Setting columns removes all contained widgets. Default is 1.
argtypedescription
sizenumberNumber of cols.
returndescription
du.widgets.grid.GridReference to the current Grid.

show

du.widgets.grid.Grid.show([on])

Shows/hides grid borders.
argtypedescription
onbooleanTrue if grid should be shown, false otherwise. optional
returndescription
du.widgets.grid.GridReference to the current Grid.

add

du.widgets.grid.Grid.add(widget, column, row, width, height)

Adds a widget to the specified row and column. If the specified cells are outside the grid or the cell is already occupied, it does not add the widget and returns null. The widget does not need to be rendered while adding, and the grid also sets positioning and size automatically. Note that the rows are measured from the top.
argtypedescription
widgetdu.widget.WidgetWidget to add.
columnnumberColumn index of the cell to add widget to.
rownumberRow index of the cell to add widget to.
widthnumberNumber of columns to occupy.
heightnumberNumber of rows to occupy.
returndescription
du.widget.WidgetReference to the added widget if cells are available and free, null pointer otherwise.

get

du.widgets.grid.Grid.get(row, column)

Returns the widget occupying the cell at the specified row and column.
argtypedescription
rownumberRow of the cell to get widget for.
columnnumberColumn of the cell to get widget for.
returndescription
du.widget.WidgetReference to the widget in the specified cell if cell is in grid and it is not empty, null pointer otherwise.