flex中datagrid合并单元格
形如: A B C
1 2 3
1 2 3
1 2 3
1 2 3
采用flex中的datagrid,现有字段A,B,C,我想合并A,B这两个标题头。也就是说标题头有两列,而下边的数据还是三列,怎么实现啊,小弟初学flex,高手指教啊!
[解决办法]
<mx:AdvancedDataGrid id="adg1" designViewDataType="flat" sortExpertMode="true" sortableColumns="false" dataProvider="{arrGrid}" width="100%" height="100%">
<mx:groupedColumns>
<mx:AdvancedDataGridColumnGroup headerText="上午">
<mx:AdvancedDataGridColumn headerText="上班"/>
<mx:AdvancedDataGridColumn headerText="下班" />
</mx:AdvancedDataGridColumnGroup>
<mx:AdvancedDataGridColumnGroup headerText="下午">
<mx:AdvancedDataGridColumn headerText="上班"/>
<mx:AdvancedDataGridColumn headerText="下班"/>
</mx:AdvancedDataGridColumnGroup>
</mx:groupedColumns>
</mx:AdvancedDataGrid>
[解决办法]
//生成Advancedatagrid
public function getForecastAdvancedDataGrid(tmpMonthADGDataGrid:AdvancedDataGrid,
forecastData:ForecastData):void{
var i:int;
myadgmonthdata=new ArrayCollection();
var tmpD:AdvancedDataGridColumn=new AdvancedDataGridColumn();
tmpD.headerText="D";
tmpD.width=90;
tmpD.itemRenderer=new ClassFactory(deleteButton);
var tmpProduct:AdvancedDataGridColumn=new AdvancedDataGridColumn("Product");
tmpProduct.dataField="1";
tmpProduct.width=100;
tmpProduct.dataField="product";
myadgmonthdata.addItem(tmpD);
myadgmonthdata.addItem(tmpProduct);
for(i=1;i<(int(forecastData.forecast_month_count)+1);++i){
var tmpGroup:AdvancedDataGridColumnGroup=new AdvancedDataGridColumnGroup();
tmpGroup.headerText=myMonth.getMonth(i,forecastData.forecast_forecast);
var tmpqty:AdvancedDataGridColumn=new AdvancedDataGridColumn();
tmpqty.headerText="QTY";
tmpqty.width=60;
tmpqty.dataField="qty"+i.toString();
var tmpup:AdvancedDataGridColumn=new AdvancedDataGridColumn();
tmpup.headerText="U/P";
tmpup.width=50;
tmpup.dataField="unitprice"+i.toString();
var tmpRevenue:AdvancedDataGridColumn=new AdvancedDataGridColumn();
tmpRevenue.headerText="Revenue";
tmpRevenue.width=80;
tmpRevenue.dataField="revenue"+i.toString();
var tmptestqty:AdvancedDataGridColumn=new AdvancedDataGridColumn();
tmptestqty.headerText="TesterQTY";
tmptestqty.width=90;
tmptestqty.dataField="testerqty"+i.toString();
tmpGroup.children=tmpGroup.children.concat(tmpqty);
tmpGroup.children=tmpGroup.children.concat(tmpRevenue);
tmpGroup.children=tmpGroup.children.concat(tmptestqty);
tmpGroup.children=tmpGroup.children.concat(tmpup);
myadgmonthdata.addItem(tmpGroup);
}
var tmpTester:AdvancedDataGridColumn=new AdvancedDataGridColumn();
tmpTester.headerText="Tester";
tmpTester.width=70;
tmpTester.dataField="tester";
var tmpHRA:AdvancedDataGridColumn=new AdvancedDataGridColumn("HR(A)");
tmpHRA.dataField="hr_a";
tmpHRA.width=60;
var tmpUPD:AdvancedDataGridColumn=new AdvancedDataGridColumn("UPD");
tmpUPD.dataField="upd";
tmpUPD.width=60;
var tmpcprod:AdvancedDataGridColumn=new AdvancedDataGridColumn();
tmpcprod.headerText="InnerProd";
tmpcprod.dataField="kprod";
tmpcprod.width=80;
var tmpoackagetype:AdvancedDataGridColumn=new AdvancedDataGridColumn();
tmpoackagetype.headerText="Package Type";
tmpoackagetype.dataField="packagetype";
var tmptesttimeunit:AdvancedDataGridColumn=new AdvancedDataGridColumn();
tmptesttimeunit.headerText="Tester Time";
tmptesttimeunit.dataField="ttime";
myadgmonthdata.addItem(tmpTester);
myadgmonthdata.addItem(tmpHRA);
myadgmonthdata.addItem(tmpUPD);
myadgmonthdata.addItem(tmpcprod);
myadgmonthdata.addItem(tmpoackagetype);
myadgmonthdata.addItem(tmptesttimeunit);
tmpMonthADGDataGrid.groupedColumns=myadgmonthdata.toArray();
}