populating child nodes question

1 posts, 0 answers
  1. Gary
    Gary avatar
    8 posts
    Member since:
    Aug 2009

    Posted 19 May 2011 Link to this post

    I've run into a little problem on my side with the radtreeview. I'm trying to build a treeview based on a folder structure on a server that will allow an user to select which folders another user has access to. I can dymanically load everything and save just fine. The problem is when I come back to a new instance of the radtreeview, I have just the basic level node (in this case folder) and the tri-state is uncheked as it doesn't have any children yet (as expected because the tree doesn't know about the folders yet).

     

    What's the best way to pre-load this list of existing checked boxes and still allow it to load the rest of the folders via ajax when the user clicks on the node. There are about 100 folders, each with about 50 subfolders which each contain another 10-50 subfolders (around 100k folders in total). Because of this, preloading will be painfully slow. The thing is that each user only has about access to 20 or so folders usually under one of the lower chains.

     

    If someone has some sample code or ideas for pre-loading specific levels, including checking only those, and then fully populating when the expand a higher level I would greatly appreciate it. I do have a web service that returns the list of folders they have access to but I'm not sure of when/how I should call it in the scope of this.

     

     

    For the loading the nodes via AJAX we use the code below (which is pretty much from the samples):

    function nodeClicked(sender, eventArgs) {
        if (!loadingPanel) {
            loadingPanel = $find(loadingPanelID);
        }
        loadingPanel.show(gridID);
        SFMT.Services.Directories.GetFilesAndFolders(sender.get_selectedNode().get_value(), updateGrid, onError, onTimeOut);
    }
    function updateGrid(result) {
        var tableView = $find(gridID).get_masterTableView();
        tableView.set_dataSource(result);
        tableView.dataBind();
        if (loadingPanel) {
            loadingPanel.hide(gridID);
        }
    }

     

    I figured I'd attempt to load the list of authorized folders in the load method (as show below) but that fails:

            var userID = '<%= UserID %>'
            function load(sender, eventArgs) {
                var tree = $find(treeID);
                var node = tree.get_nodes().getNode(0);
                if (node) {
                    SFMT.Services.Directories.GetCurrentAuthorizedFolders(userID, updateAuthList, onError, onTimeOut);
                }
            }
      
    ... Server side code
            [WebMethod(true)]
            public List<string> GetCurrentAuthorizedFolders(string userID, object context)
            {
                Dictionary<string, object> dict = (Dictionary<string, object>)context;
                if (HttpContext.Current.User.Identity.IsAuthenticated)
                {
                    if (IsAuthorizedEditor(HttpContext.Current.User.Identity.Name))
                    {
                        return DAL.LoadUserPermissionList(userID);
                    }
                }
                return new List<string>();
            }

     

     

    Actual Control:

     

    <telerik:RadTreeView ID="RadTreeView1" runat="server" CheckBoxes="True" TriStateCheckBoxes="True"
        OnClientLoad="load" OnClientNodeDataBound="nodeDataBound" OnClientNodePopulating="nodePopulating"
        OnClientNodeClicked="nodeClicked" OnClientNodePopulated="nodePopulated" Skin="Outlook">
        <WebServiceSettings Path="~/Services/Directories.asmx" Method="GetDirectories" />
        <DataBindings>
            <telerik:RadTreeNodeBinding ImageUrlField="ImageUrl" TextField="Text" ValueField="Value" />
        </DataBindings>
    </telerik:RadTreeView>

    The true problem is when I save back, if the user hasn't loaded the final nodes that are currently selected, they are lost.

Back to Top