diff options
author | Étienne Loks <etienne.loks@proxience.com> | 2015-09-29 02:43:19 +0200 |
---|---|---|
committer | Étienne Loks <etienne.loks@proxience.com> | 2015-09-29 02:43:19 +0200 |
commit | df2405cb949e268dda4c880d2685054c0eab4a80 (patch) | |
tree | e27f01bf29b9fe16dfccc157f2a1f2d6fcb872e4 /ishtar_common/widgets.py | |
parent | fa03f91834500f7589ba1912a681227186d7974e (diff) | |
download | Ishtar-df2405cb949e268dda4c880d2685054c0eab4a80.tar.bz2 Ishtar-df2405cb949e268dda4c880d2685054c0eab4a80.zip |
Display dynamicaly large tables in windows
Diffstat (limited to 'ishtar_common/widgets.py')
-rw-r--r-- | ishtar_common/widgets.py | 35 |
1 files changed, 21 insertions, 14 deletions
diff --git a/ishtar_common/widgets.py b/ishtar_common/widgets.py index 9bffe4ec5..66380db8b 100644 --- a/ishtar_common/widgets.py +++ b/ishtar_common/widgets.py @@ -524,19 +524,8 @@ class JQueryJqGrid(forms.RadioSelect): self.new, self.new_message = new, new_message self.source_full = source_full - def render(self, name, value=None, attrs=None): - t = loader.get_template('blocks/form_snippet.html') - form = self.form() - rendered = t.render(Context({'form': form})) - dct = {} - if self.new: - model_name = self.associated_model._meta.object_name.lower() - dct['url_new'] = reverse('new-' + model_name, args=['0']) - dct['new_message'] = self.new_message - extra_cols = [] - col_names, col_idx = [], [] - for k in form.get_input_ids(): - col_idx.append(u'"%s"' % k) + def get_cols(self): + col_names, extra_cols = [], [] for field_name in getattr(self.associated_model, self.table_cols): field = self.associated_model keys = field_name.split('.') @@ -557,8 +546,26 @@ class JQueryJqGrid(forms.RadioSelect): col_names.append(u'"%s"' % field_verbose_name) extra_cols.append(self.COL_TPL % {'idx': field_name}) col_names = col_names and ", ".join(col_names) or "" - col_idx = col_idx and ", ".join(col_idx) or "" extra_cols = extra_cols and ", ".join(extra_cols) or "" + return col_names, extra_cols + + def render(self, name, value=None, attrs=None): + t = loader.get_template('blocks/form_snippet.html') + form = self.form() + rendered = t.render(Context({'form': form})) + dct = {} + if self.new: + model_name = self.associated_model._meta.object_name.lower() + dct['url_new'] = reverse('new-' + model_name, args=['0']) + dct['new_message'] = self.new_message + + col_names, extra_cols = self.get_cols() + + col_idx = [] + for k in form.get_input_ids(): + col_idx.append(u'"%s"' % k) + col_idx = col_idx and ", ".join(col_idx) or "" + dct['encoding'] = settings.ENCODING or 'utf-8' dct['source'] = unicode(self.source) if unicode(self.source_full) and unicode(self.source_full) != 'None': |