tags:

views:

6398

answers:

5

I have an AdvancedDataGrid with a GroupingCollection and a SummaryRow. How do I display the summary row data in bold? Below is my code:

<mx:AdvancedDataGrid width="100%" height="100%" id="adg" defaultLeafIcon="{null}"  > 
    <mx:dataProvider>
        <mx:GroupingCollection id="gc" source="{dataProvider}">
            <mx:Grouping>
                <mx:GroupingField name="bankType">
        <mx:summaries>
                      <mx:SummaryRow summaryPlacement="group" id="summaryRow">
                        <mx:fields>
                            <mx:SummaryField dataField="t0" 
                                label="t0" operation="SUM" />
                        </mx:fields>
                      </mx:SummaryRow>
                    </mx:summaries>                    
                </mx:GroupingField>
            </mx:Grouping>
        </mx:GroupingCollection>
    </mx:dataProvider>
                  <mx:columns>
        <mx:AdvancedDataGridColumn dataField="GroupLabel" 
            headerText=""/>
        <mx:AdvancedDataGridColumn dataField="name" 
            headerText="Bank" />
        <mx:AdvancedDataGridColumn dataField="t0"
            headerText="Amount" formatter="{formatter}"/>
    </mx:columns>            

</mx:AdvancedDataGrid>
A: 

If I've understood the documentation correctly, you should be able to do this by specifying the item renderer in the rendererProviders property, and linking the summary to the rendererProvider using a dummy dataField name.

Swaroop C H
+2  A: 

in the past when I have need to do this I had to put a condition in my style function to try and determine if it is a summary row or not.

public function dataGrid_styleFunction (data:Object, column:AdvancedDataGridColumn) : Object  
{  
      var output:Object;  

      if ( data.children != null )  
      {  
          output = {color:0x081EA6, fontWeight:"bold", fontSize:14}  
      }  


      return output;  
  }

if it has children, it should be a summary row. I am not sure this is the quote/unquote right way of doing this, but it does work, at least in my uses.

HTH

Ryan Guill
i used to my project . it is working now . thank you RYanGuill
R.Vijayakumar
A: 
 private function styleCallback(data:Object, col:AdvancedDataGridColumn):Object
      {
         if (data["city"] == citySel) 
            return {color:0xFF0000,backgroundColor:0xFFF552,
            fontWeight:'bold',fontStyle:'italic'}; 

         // Return null if the Artist name does not match.
         return null;      
      }
cloverink
A: 

I wanted to format ONLY my grouping filed, so I set the styleFunction on my ADG, then in my styleCallback() method I checked for a piece of data that exists in my sub rows, but doesn't exist in my group heading.

For example I have Major headings as my groups and then rows of data with Minor headings, and descriptions, etc. So in my function I check for:

if (data["MinorHeading"] == null) return {color:0xFF0000,backgroundColor:0xFFF552,fontWeight:'bold'};

That way only my group headings get formatted in red and bold.
FYI, the backgroundColor style doesn't apply (I assume I would need a solid color Graphic Renderer to do that)

molaro