Hi there,
I have a button in my page thta should export table data to excel.
Everything worked fine before I added a script to change the style of rows based on a value.
def transform(self, value, quality, timestamp):
return [
{'style': {"backgroundColor": "#D62F2F4D" if row['VuotoErr'] > 60 else "none"}, 'value': row} for row in value
]
My button onClick event is:
def jsonToDataset(list):
columns = dict(list[0]).keys()
data = []
for item in list:
row = []
for column in columns:
cellValue = item.get(column, '')
try:
dict(cellValue)
cellValue = cellValue['value']
except:
pass
row.append(cellValue)
data.append(row)
return system.dataset.toDataSet(columns, data)
json = self.getSibling("tblDeodorazione").props.filter.results.data
if not json:
json = self.getSibling("tblDeodorazione").props.data
data = jsonToDataset(json)
Excel_xlsx = system.dataset.toExcel(True,[data])
system.perspective.download("rptDeodorazione.xlsx",Excel_xlsx)
if I write something in the table filter the output is correct:
but if I don't wrtite anything on the filter here is the result:
I think that, for sure, the problem is related to the new json structure:
But if the export script works when I have something written in the table filter, then, why it doesn't work if nothing is written there, the structure of the json doesn't change.
I do not understand.
If anyone has any suggestions I would be very grateful.
thanks