Results 1 to 3 of 3

Thread: Problem with direct

  1. #1
    Sencha User
    Join Date
    Aug 2009
    Posts
    122
    Vote Rating
    0
      0  

    Default Problem with direct

    Hello!

    I've got a problem with some Code...

    Given is a treepanel, which has included "folders". Because of big amount of "files" it's an option to show them. When user show "files", I load nodes when expanding. Server-Side it's like following: a file is created which includes all data (called with ajax request). When success, a polling-provider starts to get the first 100 entries. When request, provider stop, output all data and configure the url and start again with new parameter. Now the next 100 entries get loaded.
    Now the Problem: first 2 direct-calls are sucessfully, but next time, node isn't known and "files" aren't shown. So what can be the problem? Why does JS "loose" the node-object?
    The action is started on event 'expandnode' in treepanel.

    Hope someone can help me!

    bauchinj

  2. #2
    Sencha - Sr Software Engineer mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    39,556
    Vote Rating
    1272
      0  

    Default

    Wouldn't know without seeing code.
    Mitchell Simoens @LikelyMitch
    Sencha Inc, Senior Software Engineer
    ________________
    Learn BBCode and use it! Checkout the CODE tag!

    Check out my GitHub, lots of nice things for Ext JS and Sencha Touch
    https://github.com/mitchellsimoens

  3. #3
    Sencha User
    Join Date
    Aug 2009
    Posts
    122
    Vote Rating
    0
      0  

    Default Code

    Ok, here the code snippet:

    Code:
    Container.add({
        id            : 'someId',
        border        : false,
        width        : 700,
        style        : {
             textAlign    : 'left'
        },    
        defaults    : {
            border    : false,
        },
        items        : [{
            xtype        : 'treepanel',
            id            : 'treeId',
            rootVisible    : false,
            autoScroll    : true,
            root        : {
                nodeType    : 'async'
            },
            loader        : {
                url            : 'functions/getTree.php',
                baseParams    :{
                     id         : 'treeLoader',
                     root    : ''
                }
            },
            listeners    : {
                'expandnode'    : function(node){
                    var    getChildNodes = node.findChild('cls','file');
                     if(getChildNodes == null){
                        var nodeChecked = node.getUI().isChecked();
                        var showFiles = Ext.getCmp('showFiles').getValue();
                        if(showFiles){
                             var waitNode = new Ext.tree.TreeNode({
                                id        : 'waitNode',
                                text    : "Wait...",
                                leaf    : true,
                                cls        : 'waitNode'
                            });
                            node.appendChild(waitNode);
                            Ext.Ajax.request({
                                url        : 'functions/get_set.php',
                                params    : {
                                    action    : 'filesOfFolder',
                                    dir        : node.id,
                                    checked    : nodeChecked,
                                    source    : showFilesAction
                                },
                                success    : function(response){
                                     var first = 0;
                                     var last = 199;
                                     
                                     var fofProvider = new Ext.direct.PollingProvider({
                                        type        : 'polling',
                                        url            : 'functions/outputFof.php?folder='+node.id+'&first='+first+'&last='+last,
                                        interval    : '1000',
                                        id            : 'fofProvider'
                                    });
                                    Ext.Direct.on('message', function(e){
                                         if(fofProvider.isConnected()){
                                            var respText = e.data;
                                            if(respText == "finished"){
                                                 fofProvider.disconnect();
                                                node.removeChild(waitNode,true);            
                                            }
                                            else{
                                                 fofProvider.disconnect();
                                                 getChildNodes = node.findChild('cls','file');
                                                 
                                                 if(getChildNodes == null){
                                                     var checked = node.checked;
                                                     if(respText != "" && respText != "[]"){
                                                         var jsonNode = eval("({nodes:" + respText + "})");
                                                         var jsonArrayCt = jsonNode.nodes.length;
                                                         var newNodes;
                                                         for(var i = 0; i < jsonArrayCt; i++){
                                                             newNode = new Ext.tree.TreeNode(jsonNode.nodes[i]);
                                                            node.appendChild(newNode);
                                                        }
                                                    }
                                                }
                                                
                                                first += 200;
                                                last += 200;
                                                fofProvider.url = 'functions/outputFof.php?folder='+node.id+'&first='+first+'&last='+last;
                                                fofProvider.connect();
                                            }
                                        }
                                    });
                                    Ext.Direct.addProvider(fofProvider);
                                },
                                failure    : function(response){
                                    node.removeChild(waitNode);
                                }
                            });
                        }
                    }
                }
            }
        }]
    });

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •