web/views/tableview.py
changeset 8012 2080e476ece7
parent 8009 75638a6ff159
child 8014 6ce4ff44b2cf
equal deleted inserted replaced
8009:75638a6ff159 8012:2080e476ece7
   822         filterform.render(self.w, vid=self.__regid__, divid=divid,
   822         filterform.render(self.w, vid=self.__regid__, divid=divid,
   823                           vidargs=vidargs, cssclass=cssclass)
   823                           vidargs=vidargs, cssclass=cssclass)
   824         return self.show_hide_actions(divid, not hidden)
   824         return self.show_hide_actions(divid, not hidden)
   825 
   825 
   826     def main_var_index(self):
   826     def main_var_index(self):
   827         """returns the index of the first non-attribute variable among the RQL
   827         """Returns the index of the first non final variable of the rset.
   828         selected variables
   828 
       
   829         Used to select the main etype to help generate accurate column headers.
       
   830         XXX explain the concept
       
   831 
       
   832         May return None if none is found.
   829         """
   833         """
   830         eschema = self._cw.vreg.schema.eschema
   834         eschema = self._cw.vreg.schema.eschema
   831         for i, etype in enumerate(self.cw_rset.description[0]):
   835         for i, etype in enumerate(self.cw_rset.description[0]):
   832             try:
   836             try:
   833                 if not eschema(etype).final:
   837                 if not eschema(etype).final:
   958         box.render(w=self.w)
   962         box.render(w=self.w)
   959         self.w(u'<div class="clear"></div>')
   963         self.w(u'<div class="clear"></div>')
   960 
   964 
   961     def get_columns(self, computed_labels, displaycols, headers, subvid,
   965     def get_columns(self, computed_labels, displaycols, headers, subvid,
   962                     cellvids, cellattrs, mainindex):
   966                     cellvids, cellattrs, mainindex):
       
   967         """build columns description from various parameters
       
   968 
       
   969         : computed_labels: columns headers computed from rset to be used if there is no headers entry
       
   970         : displaycols: see :meth:`call`
       
   971         : headers: explicitly define columns headers
       
   972         : subvid: see :meth:`call`
       
   973         : cellvids: see :meth:`call`
       
   974         : cellattrs: see :meth:`call`
       
   975         : mainindex: see :meth:`call`
       
   976 
       
   977         return a list of columns description to be used by
       
   978                :class:`~cubicweb.web.htmlwidgets.TableWidget`
       
   979         """
   963         columns = []
   980         columns = []
   964         eschema = self._cw.vreg.schema.eschema
   981         eschema = self._cw.vreg.schema.eschema
   965         for colindex, label in enumerate(computed_labels):
   982         for colindex, label in enumerate(computed_labels):
   966             if colindex not in displaycols:
   983             if colindex not in displaycols:
   967                 continue
   984                 continue
   993     def render_cell(self, cellvid, row, col, w):
  1010     def render_cell(self, cellvid, row, col, w):
   994         self._cw.view('cell', self.cw_rset, row=row, col=col, cellvid=cellvid, w=w)
  1011         self._cw.view('cell', self.cw_rset, row=row, col=col, cellvid=cellvid, w=w)
   995 
  1012 
   996     def get_rows(self):
  1013     def get_rows(self):
   997         return self.cw_rset
  1014         return self.cw_rset
       
  1015 
       
  1016     def page_navigation_url(self, navcomp, path, params):
       
  1017         """Build an url to the current view using the <navcomp> attributes
       
  1018 
       
  1019         :param navcomp: a NavigationComponent to call an url method on.
       
  1020         :param path:    expected to be json here ?
       
  1021         :param params: params to give to build_url method
       
  1022 
       
  1023         this is called by :class:`cubiweb.web.component.NavigationComponent`
       
  1024         """
       
  1025         if hasattr(self, 'divid'):
       
  1026             # XXX this assert a single call
       
  1027             params['divid'] = self.divid
       
  1028         params['vid'] = self.__regid__
       
  1029         return navcomp.ajax_page_url(**params)
   998 
  1030 
   999     @htmlescape
  1031     @htmlescape
  1000     @jsonize
  1032     @jsonize
  1001     @limitsize(10)
  1033     @limitsize(10)
  1002     def sortvalue(self, row, col):
  1034     def sortvalue(self, row, col):