Hi,
I have a perspective table that returns dataset with (last row (9th row) as sum of each column).
To differentiate i would like to highlight only last row with different background color. I could posts related to json, how to do it for dataset and where to write.
Thanks in advance
You can't.
You can always use a transform to convert your dataset to a JSON:
#def transform(self, value, quality, timestamp):
dataList = []
for row in range(value.rowCount):
rowDict={}
for column in value.columnNames:
rowDict[column] = value.getValueAt(row, column)
dataList.append(rowDict)
return dataList
Then you should be able to change the background of whatever row index you want.
Edit: Removed encoding; that wouldn't be needed for this.
But i have added render view for few columns. So i would like to do this highlighting in dataset itself
Is it always going to be the same number of rows? If so, perhaps you could simply overlay a label with a semi-transparent background to give the 9th row the illusion of being highlighted.
...or sum your columns in labels under the table instead of in the last row of the table
Yes its going to be same number of rows. How to overlay only for this row
You can't within the dataset itself. Instead, just set the selected row value to the last row.
or
Or add a second table with the totals below the first. Suppress the footers on the first and suppress the headers on the second.
I have fixed this using style sheet.
.psc-row{
background-color:white;
}
.psc-row:nth-last-child(2){
background-color:#DCEDC8;
font-weight:bold;
}
.psc-row:nth-last-child(1){
background-color:#D7CCC8;
font-weight:bold;
}
Good solution.
I suggest you give a more specific name to your classes though, row
is VERY broad.
Note: You can also use column footers for totals.
And I recommend that you use Built-in Theme Colors as much as possible as these will self-adjust and preserve contrast if you ever change your theme.