开发者

Access to multiple ItemRenderers within an AdvancedDataGrid

I've create an AdvancedDataGrid where most of the cell are based on an ItemRenderer. The custom ItemRenderer (SoundBox) extends VBox. This custom component allow for simple changes in the background color based on user clicking on a cell.

Here is the snippet of the AdvancedDataGrid (nothing too advanced):

<mx:AdvancedDataGrid id="fsfw" dataProvider="{fsfWordList}" sortableColumns="false" >
开发者_高级运维   <mx:groupedColumns>
   <mx:AdvancedDataGridColumn width="35" dataField="wordcount" headerText=" "/>
   <mx:AdvancedDataGridColumn id="myWord" width="150" headerText="TEST ITEMS">
     <mx:itemRenderer>
        <mx:Component>
           <components:SoundBox width="100%" letterSound="{data.word}" />
         </mx:Component>
      </mx:itemRenderer>
   </mx:AdvancedDataGridColumn>
   <mx:AdvancedDataGridColumn width="200" headerText="Correct / 2 points" dataField="sound1">
      <mx:itemRenderer>
         <mx:Component>
            <components:SoundBox width="100%" letterSound="{data.sound1}" pointColumn="2"/>
         </mx:Component>
      </mx:itemRenderer>
   </mx:AdvancedDataGridColumn>
  </mx:groupedColumns>
</AdvancedDataGrid>   

What I'm trying to do is change the background color of (let's just say I have one row of data) row1, cell1 to green when the user clicks on cell3 of row1.

I'm unsure as to how I get access to those items (ItemRenderer/SoundBox) within the Grid.

Any Ideas? THX!


look at the following code,,, it will return the item rendrer of given row and colomn index.. Extended the Advance dataGrid and define this function in the extended class,to get it worked, then use it like "CustomADG.indicesToItemRenderer(0,0)" and in that reuturend object try to get the reference to soundComponent.

public function indicesToItemRenderer(rowIndex:int, colIndex:int):IListItemRenderer
            {
                var firstItemIndex:int = verticalScrollPosition - offscreenExtraRowsTop;
                if (rowIndex < firstItemIndex ||
                    rowIndex >= firstItemIndex + listItems.length)
                {
                    return null;
                }

                return listItems[rowIndex - firstItemIndex][colIndex];
            }
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜