AdvancedDatagrid改变行的颜色
最早我尝试重写AdvancedDatagrid的drawRowBackGrounds方法,如下:
?
override protected function drawRowBackground(s:Sprite,rowIndex:int,y:Number, height:Number, color:uint, dataIndex:int):void?
{?
if(dataProvider){
var hcv:HierarchicalCollectionView = dataProvider as HierarchicalCollectionView ;
var hd:HierarchicalData = hcv.source as HierarchicalData ;
var ac:ArrayCollection = hd.source as ArrayCollection ;
if(ac.length > 0 && dataIndex < ac.length){
var item:AlarmVO = ac[dataIndex] as AlarmVO ;
if(item.activeStatus == "0"){
color = 0xCCCCCC ;
}
}
super.drawRowBackground(s, rowIndex, y, height, color, dataIndex);
}
}
?
存在问题:当有节点打开或关闭的时候,变灰的行是错误的。
?
改进方法来自这里http://www.forestandthetrees.com/2008/10/21/adg-color-rows-by-depth/
用到了之前没了解过的类?HierarchicalCollectionViewCursor?
?
override protected function void var as //if the index is less than the length, the row has no data //content if nullif var as var switch case 1break; case 2break; case 3break; super.drawRowBackground(s,rowIndex,y,height,color,dataIndex); }
?