开发者

How to disable double click on advanced datagrid grouping title?

I have an advanced datagrid that has a grouping on it. With the items inside of the grouping I have it setup where you double click on an item and it will create a popup that allows the user to edit that entry. The problem that I am having is that I can double click on the group title and the popup is activated with blank information. How do I prevent this from working?

Here is the mxml code

<mx:AdvancedDataGrid id="plugList" designViewDataType="tree" width="100%" height="100%" 
         initialize="gc.refresh();" doubleClickEnabled="true" itemDoubleClick="plugList_itemDoubleClickHandler(event)">
        <mx:dataProvider>
            <mx:GroupingCollection2 id="gc" source="{plugs}">
                <mx:grouping>
                    <mx:Grouping>
                        <mx:GroupingField name="traderTitle"/>
                    </mx:Grouping>
                </mx:grouping>
            </mx:GroupingCollection2>
        </mx:dataProvider>
        <mx:columns>
            <mx:AdvancedDataGridColumn headerText="Title" dataField="traderTitle"/>
            <mx:AdvancedDataGridColumn headerText="Anchor" dataField="traderAnchor"/>
            <mx:AdvancedDataGridColumn headerText="URL" dataField="url"/>
            <mx:AdvancedDataGridColumn dataField="status" headerText="Status" width="75"/>
        </mx:columns>
    &l开发者_高级运维t;/mx:AdvancedDataGrid>


The event target is not the single row but the entire datagrid component, you cannot use this object. If the selectionMode property is set to singleRow (which is the default), you can use the selectedItem property to point the target row. Then you can check for the presence of the children property to distinguish between a father node and a simple leaf.

This is a simple doubleClick listener function example:

protected function plugList_itemDoubleClickHandler(event:ListEvent):void
{
    if(((Object)(event.target.selectedItem)).hasOwnProperty('children')){
        trace('not a leaf');
    }else{
        Alert.show("Selected  "+event.target.selectedItem.desc);
    }   
}

Davide


That would be handled in the plugList_itemDoubleClickHandler function. Have a conditional statement to and look at the event.target, not sure of the syntax for it off hand, but in debug mode you should be able to see a difference between the item and header that you can watch for. If its a header, dont show the popup

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜