Please refer to this post.
The main crux is the item renderer to be used by the datagrid. We can then set color of one of the column or al the columns of the selected row of datagrid.
01 | package |
02 | { |
03 | import flash.display.Graphics; |
04 | import flash.events.Event; |
05 | |
06 | import mx.controls.AdvancedDataGrid; |
07 | import mx.controls.Label; |
08 | import |
09 | mx.controls.advancedDataGridClasses.AdvancedDataGridColumn; |
10 | import mx.events.ListEvent; |
11 |
12 | public class ADGItemrenderer extends Label |
13 | { |
14 | public function ADGItemrenderer() |
15 | { |
16 | addEventListener(ListEvent.ITEM_CLICK,callInvalidate); |
17 | } |
18 | |
19 | public function callInvalidate(event:Event): void { |
20 | invalidateDisplayList(); |
21 | } |
22 | override protected function |
23 | updateDisplayList(unscaledWidth: Number , |
24 | unscaledHeight: Number ): void { |
25 | var g:Graphics = graphics; |
26 | |
27 | super .updateDisplayList(unscaledWidth, unscaledHeight); |
28 | g.clear(); |
29 | |
30 | if ( super .data){ |
31 | var advancedDataGrid:AdvancedDataGrid = |
32 | (listData)?AdvancedDataGrid((listData).owner): null ; |
33 | var column:AdvancedDataGridColumn = |
34 | (advancedDataGrid)?advancedDataGrid.columns[listData.columnIndex] |
35 | as AdvancedDataGridColumn: null ; |
36 | if (advancedDataGrid.isItemSelected(data)){ |
37 | if (data.severity < 300 ){ |
38 | /*change color accordingly*/ |
39 | g.beginFill( 0xCC0033 ); |
40 | g.drawRect( 0 , 0 , unscaledWidth, |
41 | unscaledHeight); |
42 | g.endFill(); |
43 | } else if (data.severity < 400 ){ |
44 | /*make it some other color*/ |
45 | g.beginFill( 0x00FF00 ); |
46 | g.drawRect( 0 , 0 , unscaledWidth, |
47 | unscaledHeight); |
48 | g.endFill(); |
49 | } else { |
50 | g.beginFill( 0x0000FF ); |
51 | g.drawRect( 0 , 0 , unscaledWidth, |
52 | unscaledHeight); |
53 | g.endFill(); |
54 | } |
55 | |
56 | } else { |
57 | return ; |
58 | } |
59 | } |
60 | } |
61 | } |
62 | } //Package
|
No comments:
Post a Comment