PDA

View Full Version : [CLOSED] SummaryRenderer Fn in 2.0



gets_gui
Apr 12, 2012, 1:21 PM
Hi,

I have a grid and need to compare column1 vs column3, column2 vs column4.
All four columns are summary columns.
If the values are the same, set one color; otherwise, set another color.
Here is the code in 1.3.


function colorChange(value, metadata, record, rowIndex, columnIndex) {
var col1Value= Ext.util.Format.number(record.data.colnum1, "0,000,000.00");
var col3Value= Ext.util.Format.number(record.data.column3, "0,000,000.00");
var dataIndex = clientBlocksPanel.colModel.getDataIndex(columnInde x);

if (dataIndex == "column1" || dataIndex == "column3") {
value = Ext.util.Format.number(value.toFixed(2), "0,000.00");
} else if (dataIndex == "column2" || dataIndex == "column4") {
value = Ext.util.Format.number(value, "0,000");
}

if (record.data.column2!= record.data.column4 || col1Value != col3Value) {
return '<div class="x-grid3-cell-inner" style="background-color:#FFCC33"><span style="color:black;">' + value + '</span></div>';
} else {
return '<div class="x-grid3-cell-inner" style="background-color:#00CC66"><span style="color:black;">' + value + '</span></div>';
}
}

How the above code can be implemented in 2.0?
In 2.0 the parameters for SummaryRenderer Function seems different.

Thank you.

Daniil
Apr 12, 2012, 1:31 PM
Hi,

A summaryRenderer function is called with the following paramters.



value {Object} - The calculated value.
summaryData {Object} - Contains all raw summary values for the row.
field {String} - The name of the field we are calculating



See "Rendering":
http://docs.sencha.com/ext-js/4-0/#!/api/Ext.grid.feature.Summary

gets_gui
Apr 12, 2012, 1:39 PM
Thanks.
Looks like I have to find another way to achive what I have done in 1.3.

Daniil
Apr 12, 2012, 1:44 PM
Could you clarify the requirement - you should set up custom color for summary row only or for all rows?

gets_gui
Apr 12, 2012, 2:15 PM
I need to set the color based on the summary row values for the related summary columns only in the summary row only.
Just found that I can use the summaryData, can you please advise how I access the values in summaryData?

Thanks again.

Daniil
Apr 12, 2012, 2:30 PM
It's an object like:

Example

{
field1 : 'some summary value',
field2 : 'some summary value'
}

So, you can access values this way:

summaryData.field1
or

summaryData["field1"]

gets_gui
Apr 12, 2012, 2:43 PM
Actually the attribute names in summaryData are something like "gridcolumn-1042".
I found post here and it works.
http://www.sencha.com/forum/showthread.php?176531-Grid-summaryRenderer-summaryData-names

Thank you for the help anyway.

Daniil
Apr 12, 2012, 2:46 PM
Yes, I was wrong. There are column ids as the properties names. I was sure there should be dataIndexes.