Make a Expand/Collapse button for a RadFileExplorer ?

9 posts, 0 answers
  1. Julie
    Julie avatar
    8 posts
    Member since:
    Apr 2012

    Posted 17 Apr 2012 Link to this post

    I try to make a button in order to collapse all nodes of a radFileExplorer.

            function CollapseAll(explorer, b) {
                var nodes = explorer.get_nodes();

                for (var i = 0; i < nodes.get_count(); i++) {
                    if (nodes.getNode(i).get_expanded()) {
                        nodes.getNode(i).collapse();
                    }
                }
            }

    Of course, it doesn't work. How can I access to radFileExplorer items and collapse them ?

    Thank you,
    Julie
  2. Dobromir
    Admin
    Dobromir avatar
    1633 posts

    Posted 17 Apr 2012 Link to this post

    Hi Julie,

    RadFileExplorer is using RadTreeView for its TreeView component, and you need to use the RadTreeView client-side API to achieve the required functionality. You can get nodes collection through the treeview's client-side object, e.g.:
    <telerik:RadFileExplorer ID="RadFileExplorer1" runat="server">
        <Configuration ViewPaths="~/ROOT" />
    </telerik:RadFileExplorer>
    <asp:Button Text="text" id="Button1" runat="server" OnClientClick="collapseNodes(); return false;" />
    <script type="text/javascript">
        function collapseNodes()
        {
            var explorer = $find("RadFileExplorer1");
            var tree = explorer.get_tree();
            var nodes = tree.get_allNodes();
            nodes.forEach(function (node)
            {
                if (node.get_expanded())
                    node.set_expanded(false);
            });
     
        }
    </script>


    All the best,
    Dobromir
    the Telerik team
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Julie
    Julie avatar
    8 posts
    Member since:
    Apr 2012

    Posted 18 Apr 2012 Link to this post

    Thank a lot !
  5. PJ
    PJ avatar
    5 posts
    Member since:
    Jun 2013

    Posted 15 Jun 2013 Link to this post

    How do you get the expand and collapse nodes in the first place? They only show up if I click on the refresh button.
  6. Vessy
    Admin
    Vessy avatar
    1380 posts

    Posted 19 Jun 2013 Link to this post

    Hi PJ,

    Could you elaborate more on what exactly do you mean by saying that the nodes "only show up if I click on the refresh button"? By design FileExplorer expands the child nodes of a folder, whenever the folder or the plus sign before it is clicked. Is this behavior the same on your side? Of it is not - could you provide a sample fully runnable project reproducing the problem so we could examine it on our side?

    Looking forward to hearing from you,
    Veselina Raykova
    Telerik
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to the blog feed now.
  7. PJ
    PJ avatar
    5 posts
    Member since:
    Jun 2013
  8. Ivaylo
    Admin
    Ivaylo avatar
    37 posts

    Posted 24 Jun 2013 Link to this post

    Hello P J,

    The behavior exhibited by you is not the default behavior of the FileExplorer. However, despite our efforts, we have not managed to reproduce it. I am attaching a sample video illustrating the appearance of the control on our side, which is also the expected one. Could you, please, watch it and see if we are missing something when reproducing the problem?

    Also, as my colleague has previously suggested, in order to further investigate the issue, we will need a sample project isolating it. Could you, please, prepare one and provide us with more information regarding the control's versions you are using and the browser and its version as well? On a side note, are you able to reproduce the problem in RadFileExplorer's online demo?

    Thank you for your cooperation. We will be expecting your feedback.

    Regards,
    Ivaylo
    Telerik
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to the blog feed now.
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017