Welcome | Get started | Dive | Contribute | Topics | Reference | Changes | More

lino.core.actors.atable

This module defines the AbstractTable class.

class lino.core.actors.atable.AbstractTable

Inherits from AbstractTable.

Defines a tabular table, usually displayed in a Grid (but it’s up to the user interface to decide how to implement this).

Base class for Table and VirtualTable.

column_names

Specifies which columns to show when displaying this table as a grid.

hide_zero_rows

Whether to remove rows that contain no values.

Works only in DISPLAY_MODE_HTML, other display modes ignore it. Default value is False.

Set this to True if you want

start_at_bottom

Set this to True if you want your table to start at the bottom. Unlike reverse ordering, the rows remain in their natural order, but when we open a grid on this table, we want it to start on the last page.

Default value is False.

Use cases are in lino_xl.lib.trading.InvoicesByJournal and lino_xl.lib.accounting.InvoicesByJournal and lino_patrols.lib.patrols.PatrolsHistory.

group_by

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. Default value is None.

custom_groups

Used internally to store groups defined by this Table. Default value is [].

master_field

For internal use. Automatically set to the field descriptor of the master_key. Default value is None.

get_data_rows

Maybe deprecated. Use get_request_queryset() instead.

Default value is None. 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. Default value is 1.

variable_row_height = False

Set this to True if you want each row to get the height that it needs. Default value is False.

auto_fit_column_widths = settings.SITE.auto_fit_column_widths

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.

Default value is settings.SITE.auto_fit_column_widths.

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 and FOO_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 Default value is 20.

cell_edit

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..

Default value is True.

show_detail_navigator

Whether a Detail view on a row of this table should have a navigator. Default value is True.

table_as_calendar

Whether the primereact Datatable is used to display a calendar view.

Default value is False. Used only in React front end.

get_display_mode(cls)

Return the fallback display mode to use.

max_render_depth

Used to limit the rendering of slave card views. Default value is 2.

hide_if_empty

In a detail view if a slave table is empty, it’s element will be hidden. Default value is False.

stay_in_grid

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. Default value is False.

Usage example LanguageKnowledgesByPerson.

no_phantom_row

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.

Default value is False.

order_by

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. Default value is None.

filter

If specified, this must be a django.db.models.Q object that will be passed to Django’s filter method.

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 over known_values is that this can use the full range of Django’s field lookup methods

Default value is None.

exclude

If specified, this must be a django.db.models.Q object that will be passed to Django’s exclude method.

This is the logical opposite of filter. Default value is None.

extra

Default value is 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

Set this to True if you don’t want Lino to display sums in a table view. Default value is False.

use_paging

Set this to True in Extjs6 to not use a Buffered Store, and use a JsonStore with paging instead. Default value is False.

drag_drop_sequenced_field

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 Default value is False.

If True , when the grid opens, the initial keyboard focus will be in the quick search field. Default value is False.

navigation_panel

A virtual field that displays the navigation panel for this row. This may be included in a detail layout, usually either on the left or the right side with full height.

get_filter_kw(self, 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 and Author, and a foreign key Book.author, which points to the author of the book, and a table BooksByAuthor having master_key set to 'author', then BooksByAuthor.get_filter_kw() would return a dict {‘author’: <PK>} where <PK> is the primary key of the action request’s master_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.

Or in 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.