Let each grid component have a custom name, if needed
This commit is contained in:
parent
8683e2a4c2
commit
a8a79ee326
5 changed files with 213 additions and 202 deletions
|
@ -75,7 +75,7 @@ class Grid(object):
|
|||
pageable=False, default_pagesize=20, default_page=1,
|
||||
checkboxes=False, checked=None, check_handler=None, check_all_handler=None,
|
||||
main_actions=[], more_actions=[], delete_speedbump=False,
|
||||
ajax_data_url=None,
|
||||
ajax_data_url=None, component='tailbone-grid',
|
||||
**kwargs):
|
||||
|
||||
self.key = key
|
||||
|
@ -139,8 +139,14 @@ class Grid(object):
|
|||
else:
|
||||
self.ajax_data_url = ''
|
||||
|
||||
self.component = component
|
||||
self._whgrid_kwargs = kwargs
|
||||
|
||||
@property
|
||||
def component_studly(self):
|
||||
words = self.component.split('-')
|
||||
return ''.join([word.capitalize() for word in words])
|
||||
|
||||
def make_columns(self):
|
||||
"""
|
||||
Return a default list of columns, based on :attr:`model_class`.
|
||||
|
@ -1237,8 +1243,9 @@ class Grid(object):
|
|||
results['checked_rows'] = checked
|
||||
# TODO: this seems a bit hacky, but is required for now to
|
||||
# initialize things on the client side...
|
||||
var = '{}CurrentData'.format(self.component_studly)
|
||||
results['checked_rows_code'] = '[{}]'.format(
|
||||
', '.join(['TailboneGridCurrentData[{}]'.format(i) for i in checked]))
|
||||
', '.join(['{}[{}]'.format(var, i) for i in checked]))
|
||||
|
||||
if self.pageable and self.pager is not None:
|
||||
results['total_items'] = self.pager.item_count
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue