add grid actions support
This commit is contained in:
parent
ce08699104
commit
e961e34407
3 changed files with 29 additions and 30 deletions
|
@ -218,27 +218,30 @@ class AlchemyGrid(formalchemy.Grid):
|
||||||
# qs += '&%s=%s' % (urllib.quote_plus(k), urllib.quote_plus(v))
|
# qs += '&%s=%s' % (urllib.quote_plus(k), urllib.quote_plus(v))
|
||||||
# return qs
|
# return qs
|
||||||
|
|
||||||
# def get_actions(self):
|
def get_actions(self):
|
||||||
|
"""
|
||||||
|
Returns an HTML snippet containing ``<td>`` elements for each "action"
|
||||||
|
defined in the grid.
|
||||||
|
"""
|
||||||
|
|
||||||
# def get_class(text):
|
def get_class(text):
|
||||||
# c = text.lower()
|
return text.lower().replace(' ', '-')
|
||||||
# c = c.replace(' ', '-')
|
|
||||||
# return c
|
|
||||||
|
|
||||||
# res = ''
|
res = ''
|
||||||
# for action in self.config['actions']:
|
for action in self.config['actions']:
|
||||||
# if isinstance(action, basestring):
|
if isinstance(action, basestring):
|
||||||
# text = action
|
text = action
|
||||||
# class_ = get_class(text)
|
cls = get_class(text)
|
||||||
# else:
|
else:
|
||||||
# text = action[0]
|
text = action[0]
|
||||||
# if len(action) > 1:
|
if len(action) == 2:
|
||||||
# class_ = action[1]
|
cls = action[1]
|
||||||
# else:
|
else:
|
||||||
# class_ = get_class(text)
|
cls = get_class(text)
|
||||||
# res += literal('<td class="action%s"><a href="#">%s</a></td>' %
|
res += literal(
|
||||||
# (' ' + class_ if class_ else '', text))
|
'<td class="action %s"><a href="#">%s</a></td>' %
|
||||||
# return res
|
(cls, text))
|
||||||
|
return res
|
||||||
|
|
||||||
# def get_uuid(self):
|
# def get_uuid(self):
|
||||||
# """
|
# """
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
<%inherit file="/base.mako" />
|
<%inherit file="/base.mako" />
|
||||||
|
<%def name="menu()"></%def>
|
||||||
|
|
||||||
<div class="wrapper">
|
<div class="wrapper">
|
||||||
|
|
||||||
|
|
|
@ -1,9 +1,5 @@
|
||||||
<div class="grid${' '+class_ if class_ else ''}" ${grid.url_attrs()|n}>
|
<div class="grid${' '+class_ if class_ else ''}" ${grid.url_attrs()|n}>
|
||||||
|
|
||||||
##url="${grid.url_grid}"
|
|
||||||
## objurl="${grid.url_object}" delurl="${grid.url_object}"
|
|
||||||
## usedlg="${grid.config['use_dialog']}">
|
|
||||||
|
|
||||||
<table>
|
<table>
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
|
@ -13,9 +9,9 @@
|
||||||
% for field in grid.iter_fields():
|
% for field in grid.iter_fields():
|
||||||
${grid.th_sortable(field)|n}
|
${grid.th_sortable(field)|n}
|
||||||
% endfor
|
% endfor
|
||||||
## % for i in range(len(grid.config['actions'])):
|
% for i in range(len(grid.config['actions'])):
|
||||||
## <th> </th>
|
<th> </th>
|
||||||
## % endfor
|
% endfor
|
||||||
% if grid.deletable:
|
% if grid.deletable:
|
||||||
<th> </th>
|
<th> </th>
|
||||||
% endif
|
% endif
|
||||||
|
@ -25,7 +21,6 @@
|
||||||
<tbody>
|
<tbody>
|
||||||
% for i, row in enumerate(grid.rows):
|
% for i, row in enumerate(grid.rows):
|
||||||
<% grid._set_active(row) %>
|
<% grid._set_active(row) %>
|
||||||
## <tr uuid="${grid.model.uuid}" class="${'even' if i % 2 else 'odd'}">
|
|
||||||
<tr ${grid.row_attrs(i)|n}>
|
<tr ${grid.row_attrs(i)|n}>
|
||||||
% if checkboxes:
|
% if checkboxes:
|
||||||
<td class="checkbox">${h.checkbox('check-'+grid.model.uuid, disabled=True)}</td>
|
<td class="checkbox">${h.checkbox('check-'+grid.model.uuid, disabled=True)}</td>
|
||||||
|
@ -33,10 +28,10 @@
|
||||||
% for field in grid.iter_fields():
|
% for field in grid.iter_fields():
|
||||||
<td class="${grid.field_name(field)}">${grid.render_field(field, True)|n}</td>
|
<td class="${grid.field_name(field)}">${grid.render_field(field, True)|n}</td>
|
||||||
% endfor
|
% endfor
|
||||||
## ${grid.get_actions()}
|
${grid.get_actions()}
|
||||||
%if grid.deletable:
|
% if grid.deletable:
|
||||||
<td class="delete"> </td>
|
<td class="delete"> </td>
|
||||||
%endif
|
% endif
|
||||||
</tr>
|
</tr>
|
||||||
% endfor
|
% endfor
|
||||||
</tbody>
|
</tbody>
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue