Notice
Recent Posts
Recent Comments
SNOWFLAKES DRAWING PAPER
[FLEX] Datagrid 마우스오버한 Row 인덱스값 찾기 본문
마우스 오버시 row에 rollOverColor를 데이터에 따라 색이 틀리게 적용하기 위해
DataGrid Row에 인덱스 값을 찾기위한 작업이다
먼저 DataGrid 아래 4가지 자식이 생성된다
==================================
indexNum : 0 / childName : HaloBorder37 / childFull : test_Sample0.AlertLogGrid28.dg.HaloBorder37 / X:Y=0:0 / Width:Height=795:99
indexNum : 1 / childName : mask / childFull : test_Sample0.AlertLogGrid28.dg.mask / X:Y=1:1 / Width:Height=793:97
indexNum : 2 / childName : ListBaseContentHolder32 / childFull : test_Sample0.AlertLogGrid28.dg.ListBaseContentHolder32 / X:Y=1:1 / Width:Height=793:97
indexNum : 3 / childName : DataGridHeader34 / childFull : test_Sample0.AlertLogGrid28.dg.DataGridHeader34 / X:Y=0:0 / Width:Height=0:0
indexNum : 4 / childName : instance54 / childFull : [object Shape] / X:Y=1:1 / Width:Height=793:97
==================================
이중 ListBaseContentHolder 아래에 리스트 데이터가 들어가게 되는데
rowBGs, selectionLayer, AlertLogGrid_inlineComponent1(itemRender사용), DataGridItemRenderer
자식중 rowBGs(Sprite) 아래에 rowCount(보이는 row수) 만큼 background(Shape)가 생성된다
==================================
indexNum : 0 / childName : rowBGs / childFull : test_Sample0.AlertLogGrid28.dg.ListBaseContentHolder32.rowBGs / X:Y=0:0 / Width:Height=793:97
indexNum : 1 / childName : selectionLayer / childFull : test_Sample0.AlertLogGrid28.dg.ListBaseContentHolder32.selectionLayer / X:Y=0:0 / Width:Height=793:97
indexNum : 2 / childName : AlertLogGrid_inlineComponent1_238 / childFull : test_Sample0.AlertLogGrid28.dg.ListBaseContentHolder32.AlertLogGrid_inlineComponent1_238 / X:Y=0:2 / Width:Height=88.11111111111111:21
indexNum : 3 / childName : testcv240(ItemRender한 클래스) / childFull : test_Sample0.AlertLogGrid28.dg.ListBaseContentHolder32.testcv240 / X:Y=88.10000000000001:2 / Width:Height=88.11111111111111:21
indexNum : 4 / childName : DataGridItemRenderer242 / childFull : test_Sample0.AlertLogGrid28.dg.ListBaseContentHolder32.DataGridItemRenderer242 / X:Y=176.20000000000002:2 / Width:Height=88.10000000000001:21
indexNum : 5 / childName : DataGridItemRenderer243 / childFull : test_Sample0.AlertLogGrid28.dg.ListBaseContentHolder32.DataGridItemRenderer243 / X:Y=264.3:2 / Width:Height=88.10000000000001:21
indexNum : 6 / childName : DataGridItemRenderer244 / childFull : test_Sample0.AlertLogGrid28.dg.ListBaseContentHolder32.DataGridItemRenderer244 / X:Y=352.40000000000003:2 / Width:Height=88.10000000000001:21
...
==================================
편법으로 아래와 같이 인덱스를 구하게 된다
int(Sprite(e.target.getChildAt(2).getChildByName("rowBGs")).mouseY / rowHeight) : 현재 보이는 첫번째 row가 인덱스 0 기준으로 마우스 오버된 row의 인덱스값
verticalScrollPosition : 현재 보이는 그리드의 제일위의 row 인덱스값
두가지를 더하면 row 인덱스 값이 나온다
package { import flash.display.Shape; import flash.display.Sprite; import flash.events.Event; import mx.controls.DataGrid; public class uDataGrid extends DataGrid { public function uDataGrid() { super(); } override protected function createChildren():void { super.createChildren(); addEventListener("itemRollOver", ifEvt); //addEventListener("itemRollOut", ifEvt); } private function ifEvt(e:Event):void { (getChildAt(2) as Sprite).getChildByName("selectionLayer").visible = false; uRollOver(); } private var _uRollOver:Shape; private function uRollOver():void { var idx:int =int(Sprite((getChildAt(2) as Sprite).getChildByName("rowBGs")).mouseY / rowHeight)+verticalScrollPosition; if ( _uRollOver!=null && Boolean(Sprite((getChildAt(2) as Sprite).getChildByName("rowBGs")).getChildByName("rollover")) ) { Sprite((getChildAt(2) as Sprite).getChildByName("rowBGs")).removeChild( _uRollOver ); _uRollOver = null; } _uRollOver = new Shape(); _uRollOver.name = "rollover"; _uRollOver.graphics.beginFill( uint(dataProvider[idx].rollOverColor), 1 ); _uRollOver.graphics.drawRect(0,int(Sprite((getChildAt(2) as Sprite).getChildByName("rowBGs")).mouseY / rowHeight) * rowHeight, width,rowHeight); _uRollOver.graphics.endFill(); Sprite((getChildAt(2) as Sprite).getChildByName("rowBGs")).addChild( _uRollOver ); } } } |
'개발 > FLEX/AS3/AIR/BlazeDS' 카테고리의 다른 글
[AS3] Essential ActionScript 3.0 (PDF) (0) | 2008.10.08 |
---|---|
Interface 란 무엇일까 ? (0) | 2008.10.08 |
[FLEX] DisplayObject Matrix Control (0) | 2008.10.01 |
[FLEX] Flex Builder에서 나만의 manifest 만들기 (0) | 2008.09.23 |
[FLEX] Creating a SWC Component in FlashDevelop (0) | 2008.09.22 |
Comments