145 } |
145 } |
146 |
146 |
147 def _setup_tablesorter(self, divid): |
147 def _setup_tablesorter(self, divid): |
148 self._cw.add_css('cubicweb.tablesorter.css') |
148 self._cw.add_css('cubicweb.tablesorter.css') |
149 self._cw.add_js('jquery.tablesorter.js') |
149 self._cw.add_js('jquery.tablesorter.js') |
150 print '$("#%s table").tablesorter(%s);' % (divid, js_dumps(self.tablesorter_settings)) |
150 self._cw.add_onload('''$(document).ready(function() { |
151 self._cw.add_onload('$("#%s table").tablesorter(%s);cw.log("done");' % |
151 $("#%s table").tablesorter(%s); |
152 (divid, js_dumps(self.tablesorter_settings))) |
152 });''' % (divid, js_dumps(self.tablesorter_settings))) |
153 |
153 |
154 def __init__(self, req, view, **kwargs): |
154 def __init__(self, req, view, **kwargs): |
155 super(TableLayout, self).__init__(req, **kwargs) |
155 super(TableLayout, self).__init__(req, **kwargs) |
156 for key, val in self.cw_extra_kwargs.items(): |
156 for key, val in self.cw_extra_kwargs.items(): |
157 if hasattr(self.__class__, key) and not key[0] == '_': |
157 if hasattr(self.__class__, key) and not key[0] == '_': |
175 assert self.display_filter in (None, 'top', 'bottom'), self.display_filter |
175 assert self.display_filter in (None, 'top', 'bottom'), self.display_filter |
176 if self.needs_css: |
176 if self.needs_css: |
177 self._cw.add_css(self.needs_css) |
177 self._cw.add_css(self.needs_css) |
178 if self.needs_js: |
178 if self.needs_js: |
179 self._cw.add_js(self.needs_js) |
179 self._cw.add_js(self.needs_js) |
180 print self.enable_sorting |
|
181 if self.enable_sorting: |
180 if self.enable_sorting: |
182 self._setup_tablesorter(self.view.domid) |
181 self._setup_tablesorter(self.view.domid) |
183 # Notice facets form must be rendered **outside** the main div as it |
182 # Notice facets form must be rendered **outside** the main div as it |
184 # shouldn't be rendered on ajax call subsequent to facet restriction |
183 # shouldn't be rendered on ajax call subsequent to facet restriction |
185 # (hence the 'fromformfilter' parameter added by the form |
184 # (hence the 'fromformfilter' parameter added by the form |