[CLOSED] SummaryRenderer Fn in 2.0

  1. #1

    [CLOSED] SummaryRenderer Fn in 2.0

    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(columnIndex);
                
                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.
    Last edited by Daniil; Apr 16, 2012 at 12:08 PM. Reason: [CLOSED]
  2. #2
    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/#!...eature.Summary
  3. #3
    Thanks.
    Looks like I have to find another way to achive what I have done in 1.3.
  4. #4
    Could you clarify the requirement - you should set up custom color for summary row only or for all rows?
  5. #5
    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.
  6. #6
    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"]
  7. #7
    Actually the attribute names in summaryData are something like "gridcolumn-1042".
    I found post here and it works.
    http://www.sencha.com/forum/showthre...maryData-names

    Thank you for the help anyway.
  8. #8
    Yes, I was wrong. There are column ids as the properties names. I was sure there should be dataIndexes.

Similar Threads

  1. Replies: 1
    Last Post: May 22, 2012, 3:09 PM
  2. Replies: 1
    Last Post: May 05, 2011, 3:47 PM

Posting Permissions