Author: eallen
Date: 2008-08-18 13:54:53 -0400 (Mon, 18 Aug 2008)
New Revision: 2318
Modified:
mgmt/trunk/cumin/python/wooly/tables.py
Log:
Support for hidden columns
Modified: mgmt/trunk/cumin/python/wooly/tables.py
===================================================================
--- mgmt/trunk/cumin/python/wooly/tables.py 2008-08-18 17:54:17 UTC (rev 2317)
+++ mgmt/trunk/cumin/python/wooly/tables.py 2008-08-18 17:54:53 UTC (rev 2318)
@@ -10,10 +10,13 @@
self.columns = list()
self.headers_by_column = dict()
+ self.hidden_column_names = list()
+ # which column are we sorting on
self.scolumn = Parameter(app, "col")
self.add_parameter(self.scolumn)
+ # is sort asc
self.reversed = BooleanParameter(app, "rev")
self.reversed.default = False
self.add_parameter(self.reversed)
@@ -29,6 +32,17 @@
if self.scolumn.default is None:
self.scolumn.default = column.name
+ def add_hidden_column(self, column):
+ self.add_column(column)
+ self.hide_column(column.name)
+
+ def hide_column(self, column_name):
+ self.hidden_column_names.append(column_name)
+
+ def show_column(self, column_name):
+ if column_name in self.hidden_column_names:
+ self.hidden_column_names.remove(column_name)
+
def set_header(self, column, header):
self.headers_by_column[column] = header
@@ -57,20 +71,22 @@
writer = Writer()
for column in self.columns:
- header = self.headers_by_column[column]
- writer.write(header.render(session))
+ if not column.name in self.hidden_column_names:
+ header = self.headers_by_column[column]
+ writer.write(header.render(session))
return writer.to_string()
def render_column_count(self, session, *args):
- return len(self.columns)
+ return len(self.columns) - len(self.hidden_column_names)
def render_cells(self, session, item):
writer = Writer()
for col in self.columns:
col.set_item(session, item)
- writer.write(col.render(session))
+ if not col.name in self.hidden_column_names:
+ writer.write(col.render(session))
return writer.to_string()
@@ -234,15 +250,6 @@
return writer.to_string()
- def render_cells(self, session, data):
- writer = Writer()
-
- for col in self.columns:
- col.set_item(session, data)
- writer.write(col.render(session))
-
- return writer.to_string()
-
class SqlTableColumn(ItemTableColumn):
def get_orderby_sql(self, session):
key = self.get_column_key(session)
Show replies by date