2014-12-03 52 views
0

我是ext.net的開端。我創建了一個簡單的樹,使用out數據庫中的代理進行動態加載。Ext.net如何訪問treepanel節點

@{ 
    Layout = null; 
} 

@{ 
    var thisPlugin = Model as IPlugin; 
    if (thisPlugin == null) 
    { 
     throw new Exception("IPlugin expected"); 
    } 

    var loadChildrenFunc = new Func<string>(() => 
    { 
     string retVal = Url.Action("GetChildren/" + Url.Encode(thisPlugin.Id)); 
     return retVal; 
    }); 

    var tree = Html.X().TreePanel().ID("FACILITY_TREE"); 
} 

@(tree.Title("Facility tree") 
     .Icon(Icon.Table) 
     .Frame(true) 
     .Height(450) 
     .Width(300) 
     .Border(false) 
     .Store(Html.X().TreeStore().Proxy(Html.X().AjaxProxy().Url(loadChildrenFunc()))) 
     .Root(Html.X().Node().NodeID("0").Text("Facility objects tree"))) 

Treepanel成功創建並加載節點。 我遇到的問題是訪問樹來保存它的狀態。 例如,然後展開/摺疊節點,我需要調用控制器並保存樹狀視圖狀態。所以問題是如何解決它? Anoter,點擊/雙擊後我需要調用JS函數來修改頁面上的一些數據。 請幫忙。謝謝!

回答

0

我想你需要添加一個事件監聽器。

這樣

listeners: { 
    collapse: function() { 
     alert('collapsed'); 
    }, 
    expand: function() { 
     alert('expand') 
    }, 
    itemclick: function(s,r) { 
      alert(r.data.text); 
    } 
} 

希望這有助於