Welcome | Get started | Dive | Contribute | Topics | Reference | Changes | More
lino.core.tables¶
Defines the classes AbstractTable
and
VirtualTable
.
Classes
|
An AbstractTable is the definition of a tabular data table, usually displayed in a Grid (but it's up to the user interface to decide how to implement this). |
|
Probably deprecated. |
|
|
|
For every table we create one "handle" per renderer. |
|
A mixin for tables that have a series of automatically generated columns. |
|
|
|
An |
- class lino.core.tables.TableHandle(actor)¶
Bases:
object
For every table we create one “handle” per renderer.
See also
lino.core.actors.Actor.setup_handle()
, which is called during startup and sets more attributes.
- class lino.core.tables.AbstractTable(*args, **kw)¶
Bases:
Actor
An AbstractTable is the definition of a tabular data table, usually displayed in a Grid (but it’s up to the user interface to decide how to implement this).
Base class for
Table
andVirtualTable
.- hide_zero_rows = False¶
Set this to True if you want to remove rows which contain no values when rendering this table as plain HTML. This is ignored when rendered as ExtJS.
- tablet_columns = {}¶
The columns that must remain visible when this table is rendered on a tablet device.
- mobile_columns = {}¶
The columns that must remain visible when this table is rendered on a mobile device.
- popin_columns = {}¶
The columns that must pop in below the first column if there is no space to render them on the device.
If None: All columns not listed in mobile_columns nor Tablet_columns will not pop-in.
- group_by = None¶
A list of field names that define the groups of rows in this table. Each group can have her own header and/or total lines.
- custom_groups = []¶
Used internally to store
groups
defined by this Table.
- master_field = None¶
For internal use. Automatically set to the field descriptor of the
master_key
.
- get_data_rows = None¶
Maybe deprecated. Use get_request_queryset() instead.
Virtual tables must define this method, model-based tables may define it. e.g. in case they need local filtering.
This will be called with a
lino.core.requests.ActionRequest
object and is expected to return or yield the list of “rows”:@classmethod def get_data_rows(self, ar): ... yield somerow
- row_height = 1¶
Number of text rows per data row.
- variable_row_height = False¶
Set this to True if you want each row to get the height that it needs.
- auto_fit_column_widths = True¶
Set this to True if you want to have the column widths adjusted to always fill the available width. This implies that there will be no horizontal scrollbar.
- active_fields = frozenset({})¶
A list of field names that are “active”. Value and inheritance as for
hidden_columns
.When a field is “active”, this means only that it will cause an immediate “background” save and refresh of the detail window when their value was changed. The true “activity” (i.e. other fields being updated according to the value of an active field) is defined in the model’s
full_clean
andFOO_changed
methods.Note that active fields are active only in a detail window, not in an insert window. That’s because there they would lead to the unexpected behaviour of closing the window.
- page_length = 20¶
Number of rows to display per page. Used to control the height of a combobox of a ForeignKey pointing to this model
- cell_edit = True¶
True (default) to use ExtJS CellSelectionModel, False to use RowSelectionModel. When True, the users cannot select multiple rows. When False, the users cannot edit individual cells using the F2 key..
Whether a Detail view on a row of this table should have a navigator.
- typo_check = True¶
True means that Lino shoud issue a warning if a subclass defines any attribute that did not exist in the base class. Usually such a warning means that there is something wrong.
- default_display_modes = {70: 'summary', None: 'grid'}¶
Which display mode to use in a slave panel, depending on available width.
- classmethod get_display_mode()¶
Return the fallback display mode to use.
- max_render_depth = 2¶
Used to limit the rendering of slave card views.
- hide_if_empty = False¶
In a detail view if a slave table is empty, it’s element will be hidden
- stay_in_grid = False¶
Set this to True if Lino should prefer grid mode and not open a detail window on a newly created record.
SubmitDetail
closes the window when this is True.Usage example
LanguageKnowledgesByPerson
.
- no_phantom_row = False¶
Suppress a phantom row in situations where Lino would otherwise add one.
The phantom row can disturb for example when users want to see the number of existing entries. End users can double-click on the phantom row to open an insert window and create a new item.
Used for
lino_xl.lib.accounting.ByJournal
where a phantom row is disturbing and not needed.
- order_by = None¶
If specified, this must be a tuple or list of field names that will be passed to Django’s order_by method in order to sort the rows of the queryset.
- filter = None¶
If specified, this must be a models.Q object (not a dict of (fieldname -> value) pairs) which will be passed to Django’s filter method.
Note that if you allow a user to insert rows into a filtered table, you should make sure that new records satisfy your filter condition, otherwise you can get surprising behaviour if the user creates a new row.
If your filter consists of simple static values on some known field, then you might prefer to use
known_values
instead because this will add automatic behaviour.One advantage of
filter
overknown_values
is that this can use the full range of Django’s field lookup methods
- exclude = None¶
If specified, this must be dict which will be passed to Django’s exclude method on the queryset.
- extra = None¶
Examples:
extra = dict(select=dict(lower_name='lower(name)')) # (or if you prefer:) # extra = {'select':{'lower_name':'lower(name)'},'order_by'=['lower_name']}
List of SQL functions and which RDBMS supports them: http://en.wikibooks.org/wiki/SQL_Dialects_Reference/Functions_and_expressions/String_functions
- hide_sums = False¶
Set this to True if you don’t want Lino to display sums in a table view.
- use_paging = False¶
Set this to True in Extjs6 to not use a Buffered Store, and use a JsonStore with paging instead.
- drag_drop_sequenced_field = None¶
Extjs6 only Enables drag and drop reordering for a table. Set to the field name that is used to track the order. Only used in lino.mixins.sequenced.Sequenced. Field name seqno
- focus_on_quick_search = False¶
If True , when the grid opens, the initial keyboard focus will be in the quick search field.
- classmethod parse_req(request, rqdata, **kw)¶
This is called when an incoming web request on this actor is being parsed.
If you override
parse_req()
, then keep in mind that it will be called before Lino checks the requirements. For example the user may be AnonymousUser even if the requirements won’t let it be executed. ar.subst_user.user_type may be None, e.g. when called from find_appointment inwelfare.pcsw.Clients
.
- classmethod get_row_by_pk(ar, pk)¶
dbtables.Table overrides this.
- classmethod get_column_names(ar)¶
Dynamic tables can subclass this method and return a value for
column_names
which depends on the request.
- classmethod get_filter_kw(ar, **kw)¶
Return a dict with the “master keywords” for this table and the given action request
ar
.For example, if you have two models
Book
andAuthor
, and a foreign keyBook.author
, which points to the author of the book, and a table BooksByAuthor having master_key set to'author'
, then get_filter_kw would return a dict {‘author’: <PK>} where <PK> is the primary key of the action request’smaster_instance
.Another example is
lino_xl.lib.tickets.EntriesBySession
, where blog entries are not directly linked to a session, but in the detail of a session we want to display a table of related blog entries.lino_xl.lib.households.SiblingsByPerson
Household members are not directly linked to a Person, but usually a Person is member of exactly one household, and in the Detail of a Person we want to display the members of that household.
- classmethod run_action_from_console(pk=None, an=None)¶
Not yet stable. Used by print_tx25.py. To be combined with the show management command.
- classmethod add_quick_search_filter(data, search_text)¶
Add a filter to the given data iterator in order to apply a quick search for the given search_text.
- class lino.core.tables.VirtualTable(*args, **kw)¶
Bases:
AbstractTable
An
AbstractTable
that works on an volatile (non persistent) list of rows.By nature it cannot have database fields, only virtual fields.
Subclasses must define a
get_data_rows()
method.
- class lino.core.tables.VentilatedColumns(*args, **kw)¶
Bases:
VirtualTable
A mixin for tables that have a series of automatically generated columns. TODO: rename this to DynamicColumns.
- column_names_template = ''¶
The template to use for
column_names
. It should contain a string{vcolumns}
, which will be replaced by a space-separated list of the column names given byget_ventilated_columns()
.
- class lino.core.tables.ButtonsTable(*args, **kw)¶
Bases:
VirtualTable
Probably deprecated. Might not work as expected in React (because of hide_top_toolbar).
An abstract
VirtualTable
with only one column and whose rows are action buttons.Subclasses must implement get_data_rows to yield action buttons.
Usage example lino_welfare.modlib.reception.models.FindDateByClientTable.