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
|
storeData = True
|
||||||
renderer = 'standard'
|
renderer = 'standard'
|
||||||
operator = 'in'
|
operator = 'in'
|
||||||
showTitle = True
|
|
||||||
output = None
|
output = None
|
||||||
outputWith = ()
|
outputWith = ()
|
||||||
colspan=1
|
|
||||||
colheaderspan=1
|
|
||||||
style = TableCellStyle()
|
style = TableCellStyle()
|
||||||
|
|
||||||
executionSteps = ['query', 'sort', 'output'] # , 'totals']
|
executionSteps = ['query', 'sort', 'output'] # , 'totals']
|
||||||
|
|
|
@ -20,6 +20,7 @@
|
||||||
Report result sets and related classes.
|
Report result sets and related classes.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
from copy import copy
|
||||||
from zope.cachedescriptors.property import Lazy
|
from zope.cachedescriptors.property import Lazy
|
||||||
|
|
||||||
from cybertools.composer.interfaces import IInstance
|
from cybertools.composer.interfaces import IInstance
|
||||||
|
@ -57,12 +58,24 @@ class Row(BaseRow):
|
||||||
def getGroupFields(self):
|
def getGroupFields(self):
|
||||||
return [self.getRawValue(f.name) for f in
|
return [self.getRawValue(f.name) for f in
|
||||||
self.parent.context.fields if 'group' in f.executionSteps]
|
self.parent.context.fields if 'group' in f.executionSteps]
|
||||||
|
@Lazy
|
||||||
|
def displayedColumns(self):
|
||||||
|
return self.parent.context.getActiveOutputFields()
|
||||||
|
|
||||||
|
|
||||||
class GroupHeaderRow(BaseRow):
|
class GroupHeaderRow(BaseRow):
|
||||||
|
|
||||||
def getRawValue(self, attr):
|
def getRawValue(self, attr):
|
||||||
return self.data.get(attr, u'')
|
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):
|
class ResultSet(object):
|
||||||
|
@ -77,19 +90,15 @@ class ResultSet(object):
|
||||||
self.queryCriteria = queryCriteria
|
self.queryCriteria = queryCriteria
|
||||||
self.totals = BaseRow(None, self)
|
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):
|
def getHeaderRow(self, row, columns):
|
||||||
headerRow = self.headerRowFactory(None, self)
|
headerRow = self.headerRowFactory(None, self)
|
||||||
|
headerRow.headerColumns = []
|
||||||
for c in columns:
|
for c in columns:
|
||||||
if c.output:
|
if c.output:
|
||||||
headerRow.data[c.output] = c.getRawValue(row)
|
headerRow.data[c.output] = c.getRawValue(row)
|
||||||
|
headerColumn = copy(c)
|
||||||
|
headerColumn.__name__ = c.output
|
||||||
|
headerRow.headerColumns.append(headerColumn)
|
||||||
return headerRow
|
return headerRow
|
||||||
|
|
||||||
def getResult(self):
|
def getResult(self):
|
||||||
|
|
Loading…
Add table
Reference in a new issue