web/views/tableview.py
changeset 7845 2172978be237
parent 7801 67f9677c1253
parent 7830 37d23a1d3547
child 7894 ad0eeb0f7a8d
equal deleted inserted replaced
7841:287813c487b7 7845:2172978be237
    39     It is however highly configurable and accepts a wealth of options.
    39     It is however highly configurable and accepts a wealth of options.
    40     """
    40     """
    41     __regid__ = 'table'
    41     __regid__ = 'table'
    42     title = _('table')
    42     title = _('table')
    43     finalview = 'final'
    43     finalview = 'final'
       
    44 
       
    45     table_widget_class = TableWidget
       
    46     table_column_class = TableColumn
    44 
    47 
    45     def form_filter(self, divid, displaycols, displayactions, displayfilter,
    48     def form_filter(self, divid, displaycols, displayactions, displayfilter,
    46                     paginate, hidden=True):
    49                     paginate, hidden=True):
    47         try:
    50         try:
    48             filterform = self._cw.vreg['views'].select(
    51             filterform = self._cw.vreg['views'].select(
   142             self.render_actions(divid, actions)
   145             self.render_actions(divid, actions)
   143         # render table
   146         # render table
   144         if paginate:
   147         if paginate:
   145             self.divid = divid # XXX iirk (see usage in page_navigation_url)
   148             self.divid = divid # XXX iirk (see usage in page_navigation_url)
   146             self.paginate(page_size=page_size, show_all_option=False)
   149             self.paginate(page_size=page_size, show_all_option=False)
   147         table = TableWidget(self)
   150         table = self.table_widget_class(self)
   148         for column in self.get_columns(computed_labels, displaycols, headers,
   151         for column in self.get_columns(computed_labels, displaycols, headers,
   149                                        subvid, cellvids, cellattrs, mainindex):
   152                                        subvid, cellvids, cellattrs, mainindex):
   150             table.append_column(column)
   153             table.append_column(column)
   151         table.render(self.w)
   154         table.render(self.w)
   152         self.w(u'</div>\n')
   155         self.w(u'</div>\n')
   195                 _label = headers[displaycols.index(colindex)]
   198                 _label = headers[displaycols.index(colindex)]
   196                 if _label is not None:
   199                 if _label is not None:
   197                     label = _label
   200                     label = _label
   198             if colindex == mainindex and label is not None:
   201             if colindex == mainindex and label is not None:
   199                 label += ' (%s)' % self.cw_rset.rowcount
   202                 label += ' (%s)' % self.cw_rset.rowcount
   200             column = TableColumn(label, colindex)
   203             column = self.table_column_class(label, colindex)
   201             coltype = self.cw_rset.description[0][colindex]
   204             coltype = self.cw_rset.description[0][colindex]
   202             # compute column cell view (if coltype is None, it's a left outer
   205             # compute column cell view (if coltype is None, it's a left outer
   203             # join, use the default non final subvid)
   206             # join, use the default non final subvid)
   204             if cellvids and colindex in cellvids:
   207             if cellvids and colindex in cellvids:
   205                 column.append_renderer(cellvids[colindex], colindex)
   208                 column.append_renderer(cellvids[colindex], colindex)
   257         """
   260         """
   258         :param row, col: indexes locating the cell value in view's result set
   261         :param row, col: indexes locating the cell value in view's result set
   259         :param cellvid: cell view (defaults to 'outofcontext')
   262         :param cellvid: cell view (defaults to 'outofcontext')
   260         """
   263         """
   261         etype, val = self.cw_rset.description[row][col], self.cw_rset[row][col]
   264         etype, val = self.cw_rset.description[row][col], self.cw_rset[row][col]
   262         if val is not None and etype is not None and not self._cw.vreg.schema.eschema(etype).final:
   265         if etype is None or not self._cw.vreg.schema.eschema(etype).final:
   263             self.wview(cellvid or 'outofcontext', self.cw_rset, row=row, col=col)
   266             if val is None:
   264         elif val is None:
   267                 # This is usually caused by a left outer join and in that case,
   265             # This is usually caused by a left outer join and in that case,
   268                 # regular views will most certainly fail if they don't have
   266             # regular views will most certainly fail if they don't have
   269                 # a real eid
   267             # a real eid
   270                 # XXX if cellvid is e.g. reledit, we may wanna call it anyway
   268             self.wview('final', self.cw_rset, row=row, col=col)
   271                 self.w(u'&#160;')
       
   272             else:
       
   273                 self.wview(cellvid or 'outofcontext', self.cw_rset, row=row, col=col)
   269         else:
   274         else:
       
   275             # XXX why do we need a fallback view here?
   270             self.wview(cellvid or 'final', self.cw_rset, 'null', row=row, col=col)
   276             self.wview(cellvid or 'final', self.cw_rset, 'null', row=row, col=col)
   271 
   277 
   272 
   278 
   273 class InitialTableView(TableView):
   279 class InitialTableView(TableView):
   274     """same display as  table view but consider two rql queries :
   280     """same display as  table view but consider two rql queries :