2013-04-10 83 views
2

我有一個RadFileExplorer,我的問題是我無法找到一種方式來關閉JavaScript後彈出頁面關閉節點。我的代碼不起作用。使用Javascript摺疊RadFileExplorer

function collapseNodes() { 
     $find("<%= RadAjaxPanel1.ClientID%>").ajaxRequestWithTarget("<%= RadAjaxPanel1.UniqueID %>", "Refresh"); 
     var explorer = $find("<%=RadFileExplorer1.ClientID%>"); 
     var tree = explorer.get_tree(); 
     var nodes = tree.get_allNodes(); --> this part is not working 
     nodes.forEach(function(node) { --> this part is not working 
      if (node.get_expanded())  --> this part is not working 
       node.set_expanded(false);--> this part is not working 
     }); 
    } 

<telerik:RadFileExplorer runat="server" ID="RadFileExplorer1" Width="100%" EnableOpenFile="false" 
    EnableCreateNewFolder="true" OnItemCommand="RadFileExplorer1_ItemCommand" OnExplorerPopulated="RadFileExplorer1_ExplorerPopulated" 

    DisplayUpFolderItem="false" > 
    <keyboardshortcuts delete="delete" uploadfile="Ctrl+u" newfolder="Ctrl+n" /> 
</telerik:RadFileExplorer> 

回答

0

你需要get_nodes()首先從樹視圖對象:http://www.telerik.com/help/aspnet-ajax/treeview-client-objects-radtreeview.html

然後,get_count()將返回計數,所以你可以做一個for循環,有集中的節點集合沒有的forEach方法:http://www.telerik.com/help/aspnet-ajax/treeview-client-objects-radtreenodecollection.html

只有這樣您才能使用get_expanded()和set_expanded()的給定節點的客戶端API:http://www.telerik.com/help/aspnet-ajax/treeview-client-objects-radtreenode.html。查看第一篇文章中get_nodes()方法下面的示例。