use row to get displayed Columns/ replace fields in headerRows
This commit is contained in:
parent
41b1aa2630
commit
fa7a07349d
2 changed files with 19 additions and 13 deletions
|
@ -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']
|
||||
|
|
|
@ -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,6 +58,9 @@ 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):
|
||||
|
@ -64,6 +68,15 @@ 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):
|
||||
|
|
Loading…
Add table
Reference in a new issue