Pregunta

Tengo dificultades para obtener casillas de verificación en solo los nodos de hoja de un árbol.

Antes de que alguien lo vincule, he visto http: //www.sephiroth .it / file_detail.php? id = 151 # y esto no es exactamente lo que necesito. No quiero un sistema de casilla de verificación de 3 estados que incluya rama y hoja.

Entiendo que se aplica el renderizador de elementos de casilla de verificación a una cuadrícula de datos pero no en un árbol.

Estoy usando Flex Builder 3

¿Fue útil?

Solución

Digamos que queremos poner la casilla de verificación en una de las columnas de AdvancedDataGrid. Me gusta usar HierarchicalData o HierarchicalCollectionView como el proveedor de datos de mi cuadrícula de datos:

// 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>

Eso debería ser la mayor parte. ¡Avísame, gracias!

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top