vi.widgets.table
¶
Module Contents¶
Classes¶
Provides an Html-Table which allows for row selections. |
|
Provides kind of MVC on top of SelectTable. |
- class vi.widgets.table.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.
- 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.widgets.table.DataTable(_loadOnDisplay=False, *args, **kwargs)¶
Bases:
flare.html5.Div
Provides kind of MVC on top of SelectTable.
- recalcHeight(*args, **kwargs)¶
- 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
- extend(objList)¶
Adds multiple rows at once. Much faster than calling add() multiple times.
- testIfNextBatchNeededImmediately()¶
Test if we display enough entries so that our contents are scrollable. Otherwise, we’ll never request a second batch
- 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)¶
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()¶
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
- onScroll(event)¶
Check if we got a scroll event and need to fetch another set of rows from our dataProvider
- 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.
- activateSelection()¶
Emits the selectionActivated event if there’s currently a selection