diff --git a/edbob/pyramid/grids/alchemy.py b/edbob/pyramid/grids/alchemy.py index 5bb8842..4507b3f 100644 --- a/edbob/pyramid/grids/alchemy.py +++ b/edbob/pyramid/grids/alchemy.py @@ -99,8 +99,8 @@ class AlchemyGrid(Grid): return field.render_readonly() return field.render() - def _row_attrs(self, row, i): - attrs = super(AlchemyGrid, self)._row_attrs(row, i) + def row_attrs(self, row, i): + attrs = super(AlchemyGrid, self).row_attrs(row, i) if hasattr(row, 'uuid'): attrs['uuid'] = row.uuid return attrs diff --git a/edbob/pyramid/grids/core.py b/edbob/pyramid/grids/core.py index 9cb0e94..290e8f6 100644 --- a/edbob/pyramid/grids/core.py +++ b/edbob/pyramid/grids/core.py @@ -49,7 +49,8 @@ class Grid(edbob.Object): checkboxes = False deletable = False partial_only = False - row_attrs = None + row_route_name = None + row_route_kwargs = None def __init__(self, request, **kwargs): kwargs.setdefault('fields', OrderedDict()) @@ -95,12 +96,18 @@ class Grid(edbob.Object): def render_field(self, field): raise NotImplementedError - def _row_attrs(self, row, i): + def row_attrs(self, row, i): attrs = {'class_': 'odd' if i % 2 else 'even'} return attrs def get_row_attrs(self, row, i): - attrs = self._row_attrs(row, i) - if self.row_attrs: - attrs.update(self.row_attrs(row, i)) + attrs = self.row_attrs(row, i) + if self.row_route_name: + kwargs = {} + if self.row_route_kwargs: + if callable(self.row_route_kwargs): + kwargs = self.row_route_kwargs(row) + else: + kwargs = self.row_route_kwargs + attrs['url'] = self.request.route_url(self.row_route_name, **kwargs) return format_attrs(**attrs) diff --git a/edbob/pyramid/static/js/edbob.js b/edbob/pyramid/static/js/edbob.js index d3a2447..1bda139 100644 --- a/edbob/pyramid/static/js/edbob.js +++ b/edbob/pyramid/static/js/edbob.js @@ -250,22 +250,13 @@ $(function() { $(this).removeClass('hovering'); }); - $('div.grid.clickable table tbody tr').live('click', function() { - var div = $(this).parents('div.grid:first'); - if (div.attr('usedlg') == 'True') { - var dlg = get_dialog('grid-object'); - var data = { - 'uuid': get_uuid(this), - 'partial': true, - }; - dlg.load(div.attr('objurl'), data, function() { - dlg.dialog({ - width: 500, - height: 450, - }); - }); - } else { - location.href = div.attr('objurl').replace(/%7Buuid%7D/, get_uuid(this)); + $('div.grid.clickable table tbody td').live('click', function() { + if (! $(this).hasClass('noclick')) { + var row = $(this).parents('tr:first'); + var url = row.attr('url'); + if (url) { + location.href = url; + } } }); diff --git a/edbob/pyramid/templates/grids/grid.mako b/edbob/pyramid/templates/grids/grid.mako index 78542b4..34d0b73 100644 --- a/edbob/pyramid/templates/grids/grid.mako +++ b/edbob/pyramid/templates/grids/grid.mako @@ -26,7 +26,7 @@