2011-05-09 46 views
0

我有一個如下所示的帶有TreeItemRenderer的mx:tree。在彈性樹項目渲染器中彈出

Parent1(刪除|重命名)
Child1
CHILD2
Parent2(刪除|重命名)
Child3
Child4

刪除和重命名的鏈接按鈕現在

當我點擊重新命名popup應顯示爲

OldName  : Parent1(Text Input showning present Name) 
    Enter New Name: Parent1NewName(Text Input for entering New name) 

     OK | CANCEL Buttons 

Afetr輸入新名稱,單擊確定,彈出窗口應該關閉,並需要獲取treeItemRenderer中的值。

我在檢測TreeItemRenderer重命名Parent1邏輯還我爲能夠得到Parent1在彈出OLDNAME TextInput.But輸入新的名稱IM沒能獲得新的名字在TreeItemRenderer.Please幫我後提前出局:)

+0

您的樹型數據提供程序包含哪些類型的數據? – Constantiner 2011-05-09 09:22:12

+0

xml列表集合 – 2011-05-09 10:54:47

回答

0

感謝您有兩種方式來達到自己的目標:

1)通電流XML節點到你的對話,而不是純標籤(在當前的實現)。當用戶按下確定只是新在下面的示例代碼替換舊標籤,在XML:

<?xml version="1.0" encoding="utf-8"?> 
<mx:Application layout="absolute" xmlns:mx="http://www.adobe.com/2006/mxml"> 
    <mx:Script> 
    <![CDATA[ 
     [Bindable] 
     private var rawData:XML = <tree><parent label="Parent1"><child label="Child1"/><child label="Child2"/></parent> 
       <parent label="Parent2"><child label="Child3"/><child label="Child4"/></parent></tree>; 

     private function displayLabel(node:XML):String 
     { 
      return [email protected]; 
     } 
    ]]> 
    </mx:Script> 
    <mx:VBox horizontalCenter="0" verticalCenter="0"> 
     <mx:Tree dataProvider="{rawData}" height="300" id="tree" labelFunction="displayLabel" showRoot="false" 
      width="300" /> 
     <mx:HBox enabled="{tree.selectedItem}"> 
      <mx:TextInput id="labelEdit" text="{tree.selectedItem ? [email protected] : ''}" /> 
      <mx:Button click="[email protected] = labelEdit.text" label="Apply" /> 
     </mx:HBox> 
    </mx:VBox> 
</mx:Application> 

2)label場和"labelSubmit""labelCancel"事件創建自定義事件類,並從你的對話框啓動它通過新標籤值與"labelSubmit"事件。並在對話框的事件處理程序中將新標籤設置爲XML節點(如上所述)。