Table

Using the Handsontable library

For this panel content, the panel frame url_name must be frame_table, and it must have a url_action_name for the Automail URL controller to find the panel content.

Below is an example configuration of a panel using the Table module:

{
    "title": "Default Lead-Time",
    "width": 12,
    "full_row": True,
    "url_name": "frame_table",
    "url_action_name": "table_defaultleadtimetracker",
    "content": {
        "view": api_views.Table,
        "view_params": {
            "model": custom_models.DefaultLeadTimeTracker,
            "order_by": "id",
            "init_max_rows_threshold": 20000,
            "table_settings": {
                "options": {
                    "hide_id_column": True,
                },
                "permissions": {
                    "read": {
                        "allowed": True,
                        "allowed_user_groups": [],
                        "allowed_users": [],
                    },
                    "update": {
                        "allowed": False,
                        "allowed_user_groups": [],
                        "allowed_users": [],
                    },
                    "insert": {
                        "allowed": False,
                        "allowed_user_groups": [],
                        "allowed_users": [],
                    },
                    "delete": {
                        "allowed": False,
                        "allowed_user_groups": [],
                        "allowed_users": [],
                    },
                },
            },
            "field_definitions": {
                "supplier__name": {
                    "source_include_filters": {
                        "is_t2": True
                    }
                },
                "season__search_reference_suggestion_text": {},
                "web_number": {},
                "update_timestamp": {"read_only": True},
                "user_id": {"read_only": True},
            },
            "include_filters_extra": {
                "report_category": "Delivery Report",
            },
        },
    },
}

The view_params are:

  • model the model this table is based on

  • order_by the model field (str) or fields (list) to order the table by when loading (by default ascending alphanumeric order, for descending order use the prefix "-" (e.g. "-id"))

  • is_empty sets whether the table should be empty by default until the user clicks the Search button (must have a selectpickers section on top of the page)

  • init_max_rows_threshold the maximum number of rows that will be displayed without the user clicking the Search button

  • table_settings the table-level configuration

Last updated