这两天看了一下ItemRenderer, 看到DataGridListData里有个rowIndex属性,结果在用的时候,发现它并不是我所想像的index,看了文档后才知道,这只是可见行 中的rowIndex,如果要知道某行所在DataGrid中的行数,需要用到verticalScrollPosition,也就是这样的代码:
//This renderer is a TextArea Component
override public function set data(value:Object):void{
rowIndex= (DataGridListData(listData).rowIndex +
DataGrid( DataGridListData(listData).owner).verticalScrollPosition);
}
同理,要获取columnIndex,使用
columnIndex= (DataGridListData(listData).columnIndex+
DataGrid( DataGridListData(listData).owner).horizontalScrollPosition);