use row to get displayed Columns/ replace fields in headerRows

This commit is contained in:
hplattner 2012-04-13 07:38:01 +02:00
parent 41b1aa2630
commit fa7a07349d
2 changed files with 19 additions and 13 deletions

View file

@ -73,11 +73,8 @@ class Field(Component):
storeData = True
renderer = 'standard'
operator = 'in'
showTitle = True
output = None
outputWith = ()
colspan=1
colheaderspan=1
style = TableCellStyle()
executionSteps = ['query', 'sort', 'output'] # , 'totals']

View file

@ -20,6 +20,7 @@
Report result sets and related classes.
"""
from copy import copy
from zope.cachedescriptors.property import Lazy
from cybertools.composer.interfaces import IInstance
@ -57,12 +58,24 @@ class Row(BaseRow):
def getGroupFields(self):
return [self.getRawValue(f.name) for f in
self.parent.context.fields if 'group' in f.executionSteps]
@Lazy
def displayedColumns(self):
return self.parent.context.getActiveOutputFields()
class GroupHeaderRow(BaseRow):
def getRawValue(self, attr):
return self.data.get(attr, u'')
@Lazy
def displayedColumns(self):
fields = self.parent.context.getActiveOutputFields()
for col in self.headerColumns:
for idx, f in enumerate(fields):
if f.name == col.name:
fields[idx] = col
return fields
class ResultSet(object):
@ -77,19 +90,15 @@ class ResultSet(object):
self.queryCriteria = queryCriteria
self.totals = BaseRow(None, self)
def insertHeaderRow(self, idx, result, columns):
headerRow = self.headerRowFactory(None, self)
for c in columns:
if c.output:
#headerRow.data[c.output] = c.getRawValue(result[idx])
headerRow.data[c.output] = c.getRawValue(result[idx])
result.insert(idx, headerRow)
def getHeaderRow(self, row, columns):
headerRow = self.headerRowFactory(None, self)
headerRow.headerColumns = []
for c in columns:
if c.output:
headerRow.data[c.output] = c.getRawValue(row)
headerColumn = copy(c)
headerColumn.__name__ = c.output
headerRow.headerColumns.append(headerColumn)
return headerRow
def getResult(self):