vi.framework.components.datatable
Module Contents
Classes
Provides an Html-Table which allows for row selections. |
|
- class vi.framework.components.datatable.SelectTable(checkboxes=False, indexes=False, *args, **kwargs)
Bases:
flare.ignite.Table
Provides an Html-Table which allows for row selections.
Parent widgets can register for certain events:
- selectionChanged: called if the current _multi_ selection changes. (Ie the user
holds ctrl and clicks a row). The selection might contain no, one or multiple rows. Its also called if the cursor moves. Its called if the user simply double clicks a row. So its possible to receive a selectionActivated event without an selectionChanged Event.
- selectionActivated: called if a selection is activated, ie. a row is double-clicked or Return
is pressed.
- cursorMoved: called when the currently active row changes. The user can select the current row
with a single click or by moving the cursor up and down using the arrow keys.
- onAttach()
- setHeader(headers)
Sets the table-headers to ‘headers’ :param headers: list of strings :type headers: list
- getTrByIndex(idx)
Retrieves the TR element by the given row number :param idx: Rownumber to retrieve the tr of :type idx: int :returns: HTMLTableRowElement
- getIndexByTr(tr)
Returns the rowNumber for the given tr element or None if the given tr element is invalid. :param tr: A HTMLTableRowElement of this table :type tr: HTMLTableRowElement :returns: int or None
- _rowForEvent(event)
Determines the row number for the given event
- onChange(event)
- onMouseDown(event)
- onMouseOut(event)
- onMouseUp(event)
- onKeyDown(event)
- onKeyUp(event)
- onDblClick(event)
- addSelectedRow(row)
Marks a row as selected
- removeSelectedRow(row)
Removes ‘row’ from the current selection (if any) :param row: Number of the row to unselect :type row: int
- selectRow(newRow)
Sets the current selection to ‘row’. Any previous selection is removed. :param newRow: Number of the row to select :type newRow: int
- setCursorRow(row, removeExistingSelection=True)
Move the cursor to row ‘row’. If removeExistingSelection is True, the current selection (if any) is invalidated.
- focusRow(row)
- getCurrentSelection()
Returns a list of currently selected row-numbers :returns: list
- clear()
Hook the clear() method so we can reset some internal states, too
- removeRow(row)
Hook the removeRow method so we can reset some internal states, too
- _extraCols()
- prepareCol(row, col)
Lets hook up the original removeRow function to optionally provide index and checkbox columns.
- dropTableContent()
Drops content from the table, structure remains unchanged
- setCell(row, col, val)
Interface for self[“cell”] that directs to the correct cell if extra columns are configured for this SelectTable.
- selectAll()
Selects all entries of the table.
- unSelectAll()
Unselects all entries of the table.
- invertSelection()
Inverts the current selection on the whole table currently displayed.
- class vi.framework.components.datatable.DataTable(_loadOnDisplay=False, *args, **kwargs)
Bases:
flare.html5.Div
- setDataProvider(obj)
Register’s ‘obj’ as the provider for this table. It must provide a onNextBatchNeeded function, which must fetch and feed new rows using add() or reset the dataProvider to None if no more rows are available. Notice: If the bottom of the table is reached, onNextBatchNeeded will only be called once. No further calls will be made until add() or setDataProvider() has been called afterwards.
- onCursorMoved(table, row)
Ensure the table scrolls according to the position of its cursor
- getRowCount()
Returns the total amount of rows currently known. :returns: int
- add(obj)
Adds an row to the model :param obj: Dictionary of values for this row :type obj: dict
- update(objList, writeToModel=True)
Adds multiple rows at once. Much faster than calling add() multiple times.
- extend(objList, writeToModel=True)
- remove(objOrIndex)
Removes ‘obj’ from the table. ‘obj’ may be an row-index or an object recieved by any eventListener. It _cannot_ be any original object passed to ‘add’ - it _must_ be recived by an eventListener!
- clear(keepModel=False)
Flushes the whole table.
- _renderObject(obj, tableIsPrepared=False, recalculate=True)
Renders the object to into the table. Does nothing if the list of _shownFields is empty. :param obj: Dictionary of values for this row :type obj: dict
- rebuildTable(recalculate=True)
Rebuilds the entire table. Useful if something fundamental changed (ie. the cell renderer or the list of visible fields)
- setShownFields(fields)
Sets the list of _shownFields. This causes the whole table to be rebuild. Be careful if calling this function often on a large table! :param fields: List of model-keys which will be displayed. :type fields: list
- onSelectionChanged(table, rows, *args, **kwargs)
Re-emit the event. Maps row-numbers to actual models.
- onSelectionActivated(table, rows)
Re-emit the event. Maps row-numbers to actual models.
- onTableChanged(table, rowCount, *args, **kwargs)
Re-emit the event.
- getCurrentSelection()
Override the getCurrentSelection method to yield actual models, not row-numbers.
- setCellRender(field, render)
Sets the render for cells of ‘field’ to render. A cell render receives the data for a given cell and returns the appropriate widget to display that data for the table.
- setCellRenders(renders)
Like setCellRender, but sets multiple renders at one. Much faster than calling setCellRender repeatedly.
- activateCurrentSelection()
Emits the selectionActivated event if there’s currently a selection
- class vi.framework.components.datatable.ViewportDataTable(_loadOnDisplay=False, rows=99, *args, **kwargs)
Bases:
DataTable
- clear(keepModel=False)
Flushes the whole table. Override explanation - replaced clear with dropTableContent
- rebuildTable(recalculate=True)
Rebuilds the entire table. Useful if something fundamental changed (ie. the cell renderer or the list of visible fields)#
Override explanation - uses the predefined _rows to prepare the grid - only load first rows from model
- add(obj)
Adds an row to the model :param obj: Dictionary of values for this row :type obj: dict
Override explanation - _renderObject call is always prepared
- extend(objList, writeToModel=True)
- update(objList, writeToModel=True)
Adds multiple rows at once. Much faster than calling add() multiple times.
Override explanation - removed grid preparation
- _renderObject(obj, tableIsPrepared=True, recalculate=True)
Renders the object to into the table. Does nothing if the list of _shownFields is empty. :param obj: Dictionary of values for this row :type obj: dict
Override explanation - removed Table preperation - rowIndex modulo shownrows