I new to add some rows that will have sub-totals to a Datagrid, having a special pattern. How can I do this
Use the SummaryField class to sum a column.
Import the included Flex project and view ADG_4_Summaries.mxml for the working code.
The important code is early on in the file:
var sr:SummaryRow = new SummaryRow();
var sf:SummaryField = new SummaryField("hours");
sf.label = "hourssummary";
sr.fields = [sf];
gf.summaries = [sr];
We create a summary row, then a field. The field is passed a string that references the property on each row that it should be summarizing. We define 'label' for the SummaryField that will create a new dataField that can be rendered. Finally we hook the field and summaries up to the groups.
Later on, in our ADG, we supply a rendererprovider that will give the summary it's own line. The renderer is very simple, just inherting from Label and adding some text.
<mx:AdvancedDataGridRendererProvider dataField="hourssummary"
depth="2"
columnIndex="0"
columnSpan="0"
renderer="HourSummaryRenderer"/>
+