Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 28 additions & 22 deletions dash_mantine_datatable/DataTable.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,10 @@
from typing_extensions import TypedDict, NotRequired, Literal # noqa: F401
from dash.development.base_component import Component, _explicitize_args

ComponentSingleType = typing.Union[str, int, float, Component, None]
ComponentType = typing.Union[
str,
int,
float,
Component,
None,
typing.Sequence[typing.Union[str, int, float, Component, None]],
ComponentSingleType,
typing.Sequence[ComponentSingleType],
]

NumberType = typing.Union[
Expand Down Expand Up @@ -63,8 +60,8 @@ class DataTable(Component):

- childRowsAccessor (string; default undefined):
Nested child-record accessor for already hierarchical data. When
set, rows with this accessor render inline child rows using the
same indentation and expand/collapse affordance as `groupBy`.
set, rows with this accessor render inline child rows using the
same indentation and expand/collapse affordance as `groupBy`.

- className (string; optional)

Expand All @@ -73,7 +70,7 @@ class DataTable(Component):
- columns (list of dicts; optional):
Column definitions. Each column may also define a Dash-friendly
`presentation` such as `text`, `number`, `currency`, `date`,
`datetime`, `badge`, `link`, `code`, `json` or `progress`. Set
`datetime`, `badge`, `link`, `code`, `json` or `progress`. Set
`editable=True` to enable double-click editing, and pass a Dash
input component to `editor` when you want a custom in-place
editor.
Expand All @@ -89,7 +86,7 @@ class DataTable(Component):

- direction (a value equal to: 'ltr', 'rtl'; default 'ltr'):
Layout direction. Set to `rtl` to render the table in a
right-to-left Mantine direction context.
right-to-left Mantine direction context.

- disabledSelectionRowRules (boolean | dict | list; optional)

Expand All @@ -103,6 +100,10 @@ class DataTable(Component):

- ff (string; optional)

- filterMode (a value equal to: 'client', 'server', 'none'; default 'client')

- filterValues (dict; optional)

- flex (string | number; optional)

- fs (string; optional)
Expand All @@ -113,14 +114,14 @@ class DataTable(Component):

- groupAggregations (dict; default undefined):
Per-column aggregation mapping for parent rows. Values may be one
of the built-in aggregations (`sum`, `mean`, `median`, `min`,
`max`, `count`) or a custom client-side function / function source
string.
of the built-in aggregations (`sum`, `mean`, `median`, `min`,
`max`, `count`) or a custom client-side function / function
source string.

- groupBy (string | list of strings; default undefined):
Row grouping accessor or accessors. Grouped rows render inline
nested parents inside a single table, while leaf rows can still
use `rowExpansion` for detail panels.
nested parents inside a single table, while leaf rows can still
use `rowExpansion` for detail panels.

- groups (list of dicts; default undefined):
Optional column groups matching Mantine DataTable grouped headers.
Expand All @@ -144,6 +145,8 @@ class DataTable(Component):

- lastExpansionChange (dict; optional)

- lastFilterChange (dict; optional)

- lastRowDragChange (dict; optional)

- lastSelectionChange (dict; optional)
Expand Down Expand Up @@ -289,8 +292,8 @@ class DataTable(Component):

- rowDragging (boolean | dict; optional):
Enables Dash-native row reordering. Pass `True` or a configuration
object. The reordered list is written back to both `data` and
`records`, and the latest drag payload is exposed through
object. The reordered list is written back to both `data` and
`records`, and the latest drag payload is exposed through
`lastRowDragChange`.

- rowExpansion (dict; optional)
Expand Down Expand Up @@ -340,8 +343,8 @@ class DataTable(Component):
- stickyHeaderOffset (string | number; optional)

- storeColumnsKey (string; optional):
Local-storage key used by Mantine DataTable to persist draggable /
toggleable / resizable column state.
Local-storage key used by Mantine DataTable to persist draggable
/ toggleable / resizable column state.

- striped (boolean; default False)

Expand Down Expand Up @@ -380,7 +383,7 @@ class DataTable(Component):
- withRowBorders (boolean; default True)

- withTableBorder (boolean; default True)"""
_children_props = []
_children_props: typing.List[str] = []
_base_nodes = ['children']
_namespace = 'dash_mantine_datatable'
_type = 'DataTable'
Expand All @@ -402,8 +405,10 @@ def __init__(
paginationMode: typing.Optional[Literal["client", "server", "none"]] = None,
sortMode: typing.Optional[Literal["client", "server"]] = None,
searchMode: typing.Optional[Literal["client", "server"]] = None,
filterMode: typing.Optional[Literal["client", "server", "none"]] = None,
searchQuery: typing.Optional[str] = None,
searchableAccessors: typing.Optional[typing.Sequence[str]] = None,
filterValues: typing.Optional[dict] = None,
page: typing.Optional[NumberType] = None,
recordsPerPage: typing.Optional[NumberType] = None,
pageSize: typing.Optional[NumberType] = None,
Expand Down Expand Up @@ -440,6 +445,7 @@ def __init__(
lastSortChange: typing.Optional[dict] = None,
lastSelectionChange: typing.Optional[dict] = None,
lastExpansionChange: typing.Optional[dict] = None,
lastFilterChange: typing.Optional[dict] = None,
emptyState: typing.Optional[typing.Union[str, dict]] = None,
noRecordsIcon: typing.Optional[typing.Any] = None,
noRecordsText: typing.Optional[str] = None,
Expand Down Expand Up @@ -550,9 +556,9 @@ def __init__(
visibleFrom: typing.Optional[str] = None,
**kwargs
):
self._prop_names = ['id', 'allRecordsSelectionCheckboxProps', 'backgroundColor', 'bd', 'bdrs', 'bg', 'bga', 'bgp', 'bgr', 'bgsz', 'bodyRef', 'borderColor', 'borderRadius', 'bottom', 'c', 'cellClick', 'cellContextMenu', 'cellDoubleClick', 'childRowsAccessor', 'className', 'classNames', 'columns', 'customLoader', 'data', 'defaultColumnProps', 'defaultColumnRender', 'direction', 'disabledSelectionRowRules', 'display', 'emptyState', 'expandedRecordIds', 'fetching', 'ff', 'flex', 'fs', 'fw', 'fz', 'groupAggregations', 'groupBy', 'groups', 'h', 'height', 'hiddenFrom', 'highlightOnHover', 'highlightOnHoverColor', 'horizontalSpacing', 'idAccessor', 'inset', 'lastExpansionChange', 'lastRowDragChange', 'lastSelectionChange', 'lastSortChange', 'left', 'lh', 'loaderBackgroundBlur', 'loaderColor', 'loaderSize', 'loaderType', 'loadingText', 'locale', 'lts', 'm', 'mah', 'maw', 'maxHeight', 'mb', 'me', 'mih', 'minHeight', 'miw', 'ml', 'mr', 'ms', 'mt', 'mx', 'my', 'noHeader', 'noRecordsIcon', 'noRecordsText', 'opacity', 'p', 'page', 'pageSize', 'pageSizeOptions', 'pagination', 'paginationActiveBackgroundColor', 'paginationActiveTextColor', 'paginationMode', 'paginationSize', 'paginationWithControls', 'paginationWithEdges', 'pb', 'pe', 'pinFirstColumn', 'pinLastColumn', 'pl', 'pos', 'pr', 'ps', 'pt', 'px', 'py', 'radius', 'records', 'recordsPerPage', 'recordsPerPageLabel', 'recordsPerPageOptions', 'right', 'rowAttributes', 'rowBackgroundColor', 'rowBorderColor', 'rowClassName', 'rowClick', 'rowColor', 'rowContextMenu', 'rowDoubleClick', 'rowDragging', 'rowExpansion', 'rowStyle', 'scrollAreaProps', 'scrollEdge', 'scrollPosition', 'searchMode', 'searchQuery', 'searchableAccessors', 'selectableRowRules', 'selectedRecordIds', 'selectedRecords', 'selectionCheckboxProps', 'selectionCheckboxRules', 'selectionColumnClassName', 'selectionColumnStyle', 'selectionTrigger', 'shadow', 'sortIcons', 'sortMode', 'sortStatus', 'stickyHeader', 'stickyHeaderOffset', 'storeColumnsKey', 'striped', 'stripedColor', 'style', 'styles', 'ta', 'tableClassName', 'tableProps', 'tableRef', 'td', 'textSelectionDisabled', 'top', 'totalRecords', 'tt', 'verticalAlign', 'verticalSpacing', 'visibleFrom', 'w', 'withColumnBorders', 'withRowBorders', 'withTableBorder']
self._prop_names = ['id', 'allRecordsSelectionCheckboxProps', 'backgroundColor', 'bd', 'bdrs', 'bg', 'bga', 'bgp', 'bgr', 'bgsz', 'bodyRef', 'borderColor', 'borderRadius', 'bottom', 'c', 'cellClick', 'cellContextMenu', 'cellDoubleClick', 'childRowsAccessor', 'className', 'classNames', 'columns', 'customLoader', 'data', 'defaultColumnProps', 'defaultColumnRender', 'direction', 'disabledSelectionRowRules', 'display', 'emptyState', 'expandedRecordIds', 'fetching', 'ff', 'filterMode', 'filterValues', 'flex', 'fs', 'fw', 'fz', 'groupAggregations', 'groupBy', 'groups', 'h', 'height', 'hiddenFrom', 'highlightOnHover', 'highlightOnHoverColor', 'horizontalSpacing', 'idAccessor', 'inset', 'lastExpansionChange', 'lastFilterChange', 'lastRowDragChange', 'lastSelectionChange', 'lastSortChange', 'left', 'lh', 'loaderBackgroundBlur', 'loaderColor', 'loaderSize', 'loaderType', 'loadingText', 'locale', 'lts', 'm', 'mah', 'maw', 'maxHeight', 'mb', 'me', 'mih', 'minHeight', 'miw', 'ml', 'mr', 'ms', 'mt', 'mx', 'my', 'noHeader', 'noRecordsIcon', 'noRecordsText', 'opacity', 'p', 'page', 'pageSize', 'pageSizeOptions', 'pagination', 'paginationActiveBackgroundColor', 'paginationActiveTextColor', 'paginationMode', 'paginationSize', 'paginationWithControls', 'paginationWithEdges', 'pb', 'pe', 'pinFirstColumn', 'pinLastColumn', 'pl', 'pos', 'pr', 'ps', 'pt', 'px', 'py', 'radius', 'records', 'recordsPerPage', 'recordsPerPageLabel', 'recordsPerPageOptions', 'right', 'rowAttributes', 'rowBackgroundColor', 'rowBorderColor', 'rowClassName', 'rowClick', 'rowColor', 'rowContextMenu', 'rowDoubleClick', 'rowDragging', 'rowExpansion', 'rowStyle', 'scrollAreaProps', 'scrollEdge', 'scrollPosition', 'searchMode', 'searchQuery', 'searchableAccessors', 'selectableRowRules', 'selectedRecordIds', 'selectedRecords', 'selectionCheckboxProps', 'selectionCheckboxRules', 'selectionColumnClassName', 'selectionColumnStyle', 'selectionTrigger', 'shadow', 'sortIcons', 'sortMode', 'sortStatus', 'stickyHeader', 'stickyHeaderOffset', 'storeColumnsKey', 'striped', 'stripedColor', 'style', 'styles', 'ta', 'tableClassName', 'tableProps', 'tableRef', 'td', 'textSelectionDisabled', 'top', 'totalRecords', 'tt', 'verticalAlign', 'verticalSpacing', 'visibleFrom', 'w', 'withColumnBorders', 'withRowBorders', 'withTableBorder']
self._valid_wildcard_attributes = []
self.available_properties = ['id', 'allRecordsSelectionCheckboxProps', 'backgroundColor', 'bd', 'bdrs', 'bg', 'bga', 'bgp', 'bgr', 'bgsz', 'bodyRef', 'borderColor', 'borderRadius', 'bottom', 'c', 'cellClick', 'cellContextMenu', 'cellDoubleClick', 'childRowsAccessor', 'className', 'classNames', 'columns', 'customLoader', 'data', 'defaultColumnProps', 'defaultColumnRender', 'direction', 'disabledSelectionRowRules', 'display', 'emptyState', 'expandedRecordIds', 'fetching', 'ff', 'flex', 'fs', 'fw', 'fz', 'groupAggregations', 'groupBy', 'groups', 'h', 'height', 'hiddenFrom', 'highlightOnHover', 'highlightOnHoverColor', 'horizontalSpacing', 'idAccessor', 'inset', 'lastExpansionChange', 'lastRowDragChange', 'lastSelectionChange', 'lastSortChange', 'left', 'lh', 'loaderBackgroundBlur', 'loaderColor', 'loaderSize', 'loaderType', 'loadingText', 'locale', 'lts', 'm', 'mah', 'maw', 'maxHeight', 'mb', 'me', 'mih', 'minHeight', 'miw', 'ml', 'mr', 'ms', 'mt', 'mx', 'my', 'noHeader', 'noRecordsIcon', 'noRecordsText', 'opacity', 'p', 'page', 'pageSize', 'pageSizeOptions', 'pagination', 'paginationActiveBackgroundColor', 'paginationActiveTextColor', 'paginationMode', 'paginationSize', 'paginationWithControls', 'paginationWithEdges', 'pb', 'pe', 'pinFirstColumn', 'pinLastColumn', 'pl', 'pos', 'pr', 'ps', 'pt', 'px', 'py', 'radius', 'records', 'recordsPerPage', 'recordsPerPageLabel', 'recordsPerPageOptions', 'right', 'rowAttributes', 'rowBackgroundColor', 'rowBorderColor', 'rowClassName', 'rowClick', 'rowColor', 'rowContextMenu', 'rowDoubleClick', 'rowDragging', 'rowExpansion', 'rowStyle', 'scrollAreaProps', 'scrollEdge', 'scrollPosition', 'searchMode', 'searchQuery', 'searchableAccessors', 'selectableRowRules', 'selectedRecordIds', 'selectedRecords', 'selectionCheckboxProps', 'selectionCheckboxRules', 'selectionColumnClassName', 'selectionColumnStyle', 'selectionTrigger', 'shadow', 'sortIcons', 'sortMode', 'sortStatus', 'stickyHeader', 'stickyHeaderOffset', 'storeColumnsKey', 'striped', 'stripedColor', 'style', 'styles', 'ta', 'tableClassName', 'tableProps', 'tableRef', 'td', 'textSelectionDisabled', 'top', 'totalRecords', 'tt', 'verticalAlign', 'verticalSpacing', 'visibleFrom', 'w', 'withColumnBorders', 'withRowBorders', 'withTableBorder']
self.available_properties = ['id', 'allRecordsSelectionCheckboxProps', 'backgroundColor', 'bd', 'bdrs', 'bg', 'bga', 'bgp', 'bgr', 'bgsz', 'bodyRef', 'borderColor', 'borderRadius', 'bottom', 'c', 'cellClick', 'cellContextMenu', 'cellDoubleClick', 'childRowsAccessor', 'className', 'classNames', 'columns', 'customLoader', 'data', 'defaultColumnProps', 'defaultColumnRender', 'direction', 'disabledSelectionRowRules', 'display', 'emptyState', 'expandedRecordIds', 'fetching', 'ff', 'filterMode', 'filterValues', 'flex', 'fs', 'fw', 'fz', 'groupAggregations', 'groupBy', 'groups', 'h', 'height', 'hiddenFrom', 'highlightOnHover', 'highlightOnHoverColor', 'horizontalSpacing', 'idAccessor', 'inset', 'lastExpansionChange', 'lastFilterChange', 'lastRowDragChange', 'lastSelectionChange', 'lastSortChange', 'left', 'lh', 'loaderBackgroundBlur', 'loaderColor', 'loaderSize', 'loaderType', 'loadingText', 'locale', 'lts', 'm', 'mah', 'maw', 'maxHeight', 'mb', 'me', 'mih', 'minHeight', 'miw', 'ml', 'mr', 'ms', 'mt', 'mx', 'my', 'noHeader', 'noRecordsIcon', 'noRecordsText', 'opacity', 'p', 'page', 'pageSize', 'pageSizeOptions', 'pagination', 'paginationActiveBackgroundColor', 'paginationActiveTextColor', 'paginationMode', 'paginationSize', 'paginationWithControls', 'paginationWithEdges', 'pb', 'pe', 'pinFirstColumn', 'pinLastColumn', 'pl', 'pos', 'pr', 'ps', 'pt', 'px', 'py', 'radius', 'records', 'recordsPerPage', 'recordsPerPageLabel', 'recordsPerPageOptions', 'right', 'rowAttributes', 'rowBackgroundColor', 'rowBorderColor', 'rowClassName', 'rowClick', 'rowColor', 'rowContextMenu', 'rowDoubleClick', 'rowDragging', 'rowExpansion', 'rowStyle', 'scrollAreaProps', 'scrollEdge', 'scrollPosition', 'searchMode', 'searchQuery', 'searchableAccessors', 'selectableRowRules', 'selectedRecordIds', 'selectedRecords', 'selectionCheckboxProps', 'selectionCheckboxRules', 'selectionColumnClassName', 'selectionColumnStyle', 'selectionTrigger', 'shadow', 'sortIcons', 'sortMode', 'sortStatus', 'stickyHeader', 'stickyHeaderOffset', 'storeColumnsKey', 'striped', 'stripedColor', 'style', 'styles', 'ta', 'tableClassName', 'tableProps', 'tableRef', 'td', 'textSelectionDisabled', 'top', 'totalRecords', 'tt', 'verticalAlign', 'verticalSpacing', 'visibleFrom', 'w', 'withColumnBorders', 'withRowBorders', 'withTableBorder']
self.available_wildcard_properties = []
_explicit_args = kwargs.pop('_explicit_args')
_locals = locals()
Expand Down
50 changes: 48 additions & 2 deletions dash_mantine_datatable/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,8 @@
"default_column_render": "defaultColumnRender",
"dir": "direction",
"disabled_selection_row_rules": "disabledSelectionRowRules",
"filter_mode": "filterMode",
"filter_values": "filterValues",
"fontSize": "fz",
"group_aggregations": "groupAggregations",
"group_by": "groupBy",
Expand All @@ -97,12 +99,10 @@
_EXTRA_CHILDREN_PROPS = (
"columns[].render",
"columns[].editor",
"columns[].filter",
"columns[].footer",
"customLoader",
"defaultColumnProps.render",
"defaultColumnProps.editor",
"defaultColumnProps.filter",
"defaultColumnProps.footer",
"defaultColumnRender",
"emptyState",
Expand Down Expand Up @@ -1733,6 +1733,43 @@ def update_search(self, **kwargs: Any) -> "DataTable":
"""
return self._update_props(**kwargs)

def update_filters(self, **kwargs: Any) -> "DataTable":
"""
Description
-----------
Update column-filter state and mode in place.

Parameters
----------
filterMode : str, optional
Description: Chooses where column filter values are applied.
Expected inputs: `'client'`, `'server'`, `'none'`.
Example: `filterMode="client"`.
filterValues : dict, optional
Description: Controlled mapping of column accessors to filter
values. The table also writes this prop when filter components
change.
Example: `filterValues={"name": "avery", "team": ["Platform"]}`.

Returns
-------
DataTable
The current instance.

Notes
-----
Client mode is the default: DMC filter components rendered in column
popovers are wired internally and combined with search, sorting, and
pagination. In server mode, the table still reports `filterValues` and
`lastFilterChange` so a Dash callback can fetch data.

Examples
--------
>>> table.update_filters(filterMode="server")
DataTable(...)
"""
return self._update_props(**kwargs)

def clear_selection(self) -> "DataTable":
"""
Description
Expand Down Expand Up @@ -2071,6 +2108,15 @@ def _set_doc_signature(target: Any, parameters: list[inspect.Parameter]) -> None
],
)

_set_doc_signature(
DataTable.update_filters,
[
_doc_parameter("self", kind=inspect.Parameter.POSITIONAL_OR_KEYWORD),
_doc_parameter("filterMode", default=None),
_doc_parameter("filterValues", default=None),
],
)


__all__ = [
"Column",
Expand Down
2 changes: 1 addition & 1 deletion dash_mantine_datatable/dash_mantine_datatable.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dash_mantine_datatable/dash_mantine_datatable.min.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dash_mantine_datatable/metadata.json

Large diffs are not rendered by default.

Loading
Loading