fix: add basic checkbox support for grids
This commit is contained in:
parent
6dfb35b688
commit
7ba4987003
|
@ -118,6 +118,11 @@ class Grid:
|
||||||
See also :meth:`set_renderer()` and
|
See also :meth:`set_renderer()` and
|
||||||
:meth:`set_default_renderers()`.
|
:meth:`set_default_renderers()`.
|
||||||
|
|
||||||
|
.. attribute:: checkable
|
||||||
|
|
||||||
|
Boolean indicating whether the grid should expose per-row
|
||||||
|
checkboxes.
|
||||||
|
|
||||||
.. attribute:: row_class
|
.. attribute:: row_class
|
||||||
|
|
||||||
This represents the CSS ``class`` attribute for a row within
|
This represents the CSS ``class`` attribute for a row within
|
||||||
|
@ -362,6 +367,7 @@ class Grid:
|
||||||
data=None,
|
data=None,
|
||||||
labels={},
|
labels={},
|
||||||
renderers={},
|
renderers={},
|
||||||
|
checkable=False,
|
||||||
row_class=None,
|
row_class=None,
|
||||||
actions=[],
|
actions=[],
|
||||||
linked_columns=[],
|
linked_columns=[],
|
||||||
|
@ -388,6 +394,7 @@ class Grid:
|
||||||
self.key = key
|
self.key = key
|
||||||
self.data = data
|
self.data = data
|
||||||
self.labels = labels or {}
|
self.labels = labels or {}
|
||||||
|
self.checkable = checkable
|
||||||
self.row_class = row_class
|
self.row_class = row_class
|
||||||
self.actions = actions or []
|
self.actions = actions or []
|
||||||
self.linked_columns = linked_columns or []
|
self.linked_columns = linked_columns or []
|
||||||
|
|
|
@ -116,6 +116,13 @@
|
||||||
hoverable
|
hoverable
|
||||||
icon-pack="fas"
|
icon-pack="fas"
|
||||||
|
|
||||||
|
## checkboxes
|
||||||
|
% if grid.checkable:
|
||||||
|
checkable
|
||||||
|
checkbox-position="right"
|
||||||
|
:checked-rows.sync="checkedRows"
|
||||||
|
% endif
|
||||||
|
|
||||||
## sorting
|
## sorting
|
||||||
% if grid.sortable:
|
% if grid.sortable:
|
||||||
## nb. buefy/oruga only support *one* default sorter
|
## nb. buefy/oruga only support *one* default sorter
|
||||||
|
@ -267,6 +274,11 @@
|
||||||
shareLink: null,
|
shareLink: null,
|
||||||
% endif
|
% endif
|
||||||
|
|
||||||
|
## checkboxes
|
||||||
|
% if grid.checkable:
|
||||||
|
checkedRows: [],
|
||||||
|
% endif
|
||||||
|
|
||||||
## filtering
|
## filtering
|
||||||
% if grid.filterable:
|
% if grid.filterable:
|
||||||
filters: ${json.dumps(grid.get_vue_filters())|n},
|
filters: ${json.dumps(grid.get_vue_filters())|n},
|
||||||
|
|
|
@ -189,6 +189,12 @@ class MasterView(View):
|
||||||
|
|
||||||
This is optional; see also :meth:`get_grid_columns()`.
|
This is optional; see also :meth:`get_grid_columns()`.
|
||||||
|
|
||||||
|
.. attribute:: checkable
|
||||||
|
|
||||||
|
Boolean indicating whether the grid should expose per-row
|
||||||
|
checkboxes. This is passed along to set
|
||||||
|
:attr:`~wuttaweb.grids.base.Grid.checkable` on the grid.
|
||||||
|
|
||||||
.. method:: grid_row_class(obj, data, i)
|
.. method:: grid_row_class(obj, data, i)
|
||||||
|
|
||||||
This method is *not* defined on the ``MasterView`` base class;
|
This method is *not* defined on the ``MasterView`` base class;
|
||||||
|
@ -395,6 +401,7 @@ class MasterView(View):
|
||||||
# features
|
# features
|
||||||
listable = True
|
listable = True
|
||||||
has_grid = True
|
has_grid = True
|
||||||
|
checkable = False
|
||||||
filterable = True
|
filterable = True
|
||||||
filter_defaults = None
|
filter_defaults = None
|
||||||
sortable = True
|
sortable = True
|
||||||
|
@ -1992,6 +1999,7 @@ class MasterView(View):
|
||||||
|
|
||||||
kwargs['tools'] = tools
|
kwargs['tools'] = tools
|
||||||
|
|
||||||
|
kwargs.setdefault('checkable', self.checkable)
|
||||||
if hasattr(self, 'grid_row_class'):
|
if hasattr(self, 'grid_row_class'):
|
||||||
kwargs.setdefault('row_class', self.grid_row_class)
|
kwargs.setdefault('row_class', self.grid_row_class)
|
||||||
kwargs.setdefault('filterable', self.filterable)
|
kwargs.setdefault('filterable', self.filterable)
|
||||||
|
|
Loading…
Reference in a new issue