How do I change the state in an itemRenderer based on an action in another itemRenderer?

I have a DataGridColumn with an ItemRenderer that extends a Box component. The default display is a Text component. When the user clicks on the text component, I change the state to add a PopUpMenuButton child and make the text component invisible. This works great. However, I want one PopUpMenuButton instance to be visible in the DataGrid at a time (similar to how ItemEditor works). I don't want to use itemEditor because I am having too many problems trying to get this to work on this instance.

I am implementing IDropInListItemRenderer in my itemRenderer to access the listData property which will give me the owner (DataGrid), but I don't know how to "disable" the "edit" state in other itemRenderers in the DataGrid.

How can i do this?

Thank.

0


source to share


1 answer


Here we go. I just added a Listener for event changes to listData.owner - if it's running, I update currentState to null. Works like a charm. Much easier than trying to access the itemRenderers on a column and reset all of them. Better to work too.



private function label_clickHandler():void
{
    showEditor();
}

private function showEditor():void
{
    this.currentState = "editingMode";

    var ownerListBase:ListBase = ListBase(listData.owner);

    ownerListBase.addEventListener(ListEvent.CHANGE, ownerListBase_changeHandler);
}

private function ownerListBase_changeHandler(event:ListEvent):void
{
    this.currentState = null;

    var ownerListBase:ListBase = ListBase(listData.owner);

    ownerListBase.removeEventListener(ListEvent.CHANGE, ownerListBase_changeHandler);
}

      

0


source







All Articles