Add initial support for grid index URLs
Yay, been wanting this for some time now.
This commit is contained in:
parent
70a2f10c81
commit
abb42e9f25
5 changed files with 80 additions and 25 deletions
|
@ -590,24 +590,23 @@ class Grid(object):
|
|||
"""
|
||||
return bool(self.main_actions or self.more_actions)
|
||||
|
||||
def render_actions(self, row):
|
||||
def render_actions(self, row, i):
|
||||
"""
|
||||
Returns the rendered contents of the 'actions' column for a given row.
|
||||
"""
|
||||
main_actions = filter(None, [self.render_action(a, row) for a in self.main_actions])
|
||||
more_actions = filter(None, [self.render_action(a, row) for a in self.more_actions])
|
||||
main_actions = filter(None, [self.render_action(a, row, i) for a in self.main_actions])
|
||||
more_actions = filter(None, [self.render_action(a, row, i) for a in self.more_actions])
|
||||
if more_actions:
|
||||
icon = HTML.tag('span', class_='ui-icon ui-icon-carat-1-e')
|
||||
link = tags.link_to("More" + icon, '#', class_='more')
|
||||
main_actions.append(link + HTML.tag('div', class_='more', c=more_actions))
|
||||
# main_actions.append(tags.link_to("More" + icon + HTML.literal('').join(more_actions), '#', class_='more'))
|
||||
return HTML.literal('').join(main_actions)
|
||||
|
||||
def render_action(self, action, row):
|
||||
def render_action(self, action, row, i):
|
||||
"""
|
||||
Renders an action menu item (link) for the given row.
|
||||
"""
|
||||
url = action.get_url(row)
|
||||
url = action.get_url(row, i)
|
||||
if url:
|
||||
kwargs = {'class_': action.key}
|
||||
if action.icon:
|
||||
|
@ -711,10 +710,10 @@ class GridAction(object):
|
|||
self.icon = icon
|
||||
self.url = url
|
||||
|
||||
def get_url(self, row):
|
||||
def get_url(self, row, i):
|
||||
"""
|
||||
Returns an action URL for the given row.
|
||||
"""
|
||||
if callable(self.url):
|
||||
return self.url(row)
|
||||
return self.url(row, i)
|
||||
return self.url
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue