2009-09-16 83 views

回答

0

比方說,我們希望把複選框中AdvancedDataGrid的列之一。我喜歡用HierarchicalData或HierarchicalCollectionView作爲我的DataGrid的dataProvider:

// TestGrid 
<mx:AdvancedDataGrid id="myADG"> 
    <mx:columns> 
     <AdvancedDataGridColumn id="col1" /> 
     <AdvancedDataGridColumn id="col2" itemRenderer="LeafCheckbox" /> 
    </mx:columns> 
</mx:AdvancedDataGrid> 



// LeafCheckBox.mxml 
<mx:Box 
    creationComplete="init(event)" 
    implements="IDropInListItemRenderer"> 
<mx:Script> 
    <![CDATA[ 

    // Internal variable for the property value. 
    private var _listData:BaseListData; 

    // Make the listData property bindable. 
    [Bindable("dataChange")] 

    // Define the getter method. 
    public function get listData():BaseListData 
    { 
     return _listData; 
    } 

    // Define the setter method, 
    public function set listData(value:BaseListData):void 
    { 
     _listData = value; 
    } 


    private function init(event:Event):void { 
     var dg:AdvancedDataGrid = this.listData.owner.parent as AdvancedDataGrid; 
     if (!dg.dataProvider.hasChildren(dg.selectedItem)) 
      this.addChild(new CheckBox()); 
    } 

    ]]> 
</mx:Script> 

</mx:Box> 

這應該是大部分。讓我知道,謝謝!

相關問題