691 |
691 |
692 .. automethod:: cubicweb.web.views.tableview.EntityTableColRenderer.entity |
692 .. automethod:: cubicweb.web.views.tableview.EntityTableColRenderer.entity |
693 .. automethod:: cubicweb.web.views.tableview.EntityTableColRenderer.render_entity |
693 .. automethod:: cubicweb.web.views.tableview.EntityTableColRenderer.render_entity |
694 .. automethod:: cubicweb.web.views.tableview.EntityTableColRenderer.entity_sortvalue |
694 .. automethod:: cubicweb.web.views.tableview.EntityTableColRenderer.entity_sortvalue |
695 """ |
695 """ |
696 def __init__(self, renderfunc=None, sortfunc=None, **kwargs): |
696 def __init__(self, renderfunc=None, sortfunc=None, sortable=None, **kwargs): |
697 if renderfunc is None: |
697 if renderfunc is None: |
698 renderfunc = self.render_entity |
698 renderfunc = self.render_entity |
699 if sortfunc is None: |
699 # if renderfunc nor sortfunc nor sortable specified, column will be |
700 sortfunc = self.entity_sortvalue |
700 # sortable using the default implementation. |
701 kwargs.setdefault('sortable', sortfunc is not None) |
701 if sortable is None: |
702 super(EntityTableColRenderer, self).__init__(**kwargs) |
702 sortable = True |
|
703 # no sortfunc given but asked to be sortable: use the default sort |
|
704 # method. Sub-class may set `entity_sortvalue` to None if they don't |
|
705 # support sorting. |
|
706 if sortfunc is None and sortable: |
|
707 sortfunc = self.entity_sortvalue |
|
708 # at this point `sortable` may still be unspecified while `sortfunc` is |
|
709 # sure to be set to someting else than None if the column is sortable. |
|
710 sortable = sortfunc is not None |
|
711 super(EntityTableColRenderer, self).__init__(sortable=sortable, **kwargs) |
703 self.renderfunc = renderfunc |
712 self.renderfunc = renderfunc |
704 self.sortfunc = sortfunc |
713 self.sortfunc = sortfunc |
705 |
714 |
706 def copy(self): |
715 def copy(self): |
707 assert self.view is None |
716 assert self.view is None |