diff --git a/tailbone/grids/core.py b/tailbone/grids/core.py index d5c3ef62..e8c963a6 100644 --- a/tailbone/grids/core.py +++ b/tailbone/grids/core.py @@ -56,7 +56,7 @@ class Grid(object): joiners={}, filterable=False, filters={}, sortable=False, sorters={}, default_sortkey=None, default_sortdir='asc', pageable=False, default_pagesize=20, default_page=1, - checkboxes=False, main_actions=[], more_actions=[], + checkboxes=False, checked=None, main_actions=[], more_actions=[], **kwargs): self.key = key @@ -90,6 +90,9 @@ class Grid(object): self.default_page = default_page self.checkboxes = checkboxes + self.checked = checked + if self.checked is None: + self.checked = lambda item: False self.main_actions = main_actions self.more_actions = more_actions @@ -882,13 +885,6 @@ class Grid(object): """ return True - def checked(self, item): - """ - Returns boolean indicating whether the given item's row checkbox should - be checked, for initial page load. - """ - return False - def render_checkbox(self, item): """ Renders a checkbox cell for the given item, if applicable. diff --git a/tailbone/views/master2.py b/tailbone/views/master2.py index e6b22c23..68483f31 100644 --- a/tailbone/views/master2.py +++ b/tailbone/views/master2.py @@ -258,6 +258,7 @@ class MasterView2(MasterView): 'url': lambda obj: self.get_action_url('view', obj), 'checkboxes': self.checkboxes or ( self.mergeable and self.request.has_perm('{}.merge'.format(self.get_permission_prefix()))), + 'checked': self.checked, } if 'main_actions' not in kwargs and 'more_actions' not in kwargs: main, more = self.get_grid_actions()