1. #1
    Ext User
    Join Date
    Sep 2009
    Location
    Paris
    Posts
    7
    Vote Rating
    0
    Aurélien LEQUOY is on a distinguished road

      0  

    Question [SOLVED] Probleme with the example Direct TreeLoader

    [SOLVED] Probleme with the example Direct TreeLoader


    I am new in ExtJS (It's my first try), perhaps someone can help me


    first the 2 files that I make some modification :


    direct-tree.js
    Code:
    Ext.onReady
    (
        function()
        {
            
            Ext.Direct.addProvider(Ext.app.REMOTING_API);
    
            var tree = new Ext.tree.TreePanel
            (
                {
                    autoScroll: true,
                    renderTo: document.getElementById('menu_cadre_arbre'),
                    animate: true, //lol
    
                    root: {
                        expanded:true,
                        useArrows: false,
                        id: 'n.1', //.1.1.9.101.438
                        text: '<a href="index.php?page=ddd#ee"><b>Estrildidae</b></a>',
                                listeners: {
                click: function(n) {
                    Ext.Msg.alert('Navigation Tree Click', 'You clicked: "' + n.attributes.text + '"');
                }
            }
    
                        
                    },
                    
                    loader: 
                    new Ext.tree.TreeLoader
                    (
                        {
                            preloadChilren: true,
                            directFn: TestAction.getTree
                        }
                    ),
                }
                
            );
            
            
            tree.getRootNode().reload();
            //createNode: 'n.1.1.1.9.101.438',
        
        
        return true;
    
        }
    
    );
    TestAction.php (only 10 values whasn't enough for me)
    PHP Code:
    <?php



    class TestAction
    {
       
        
        function 
    doEcho($data){
            return 
    $data;
        }

        function 
    multiply($num){
            if(!
    is_numeric($num)){
                throw new 
    Exception('Call to multiply with a value that is not a number');
            }
            return 
    $num*8;
        }

        function 
    getTree($id)
        {
            include 
    "/media/usbdisk/www/species/config.php";
            include 
    "/media/usbdisk/www/species/class/sql.lib.php";
            
            
    $out = array();
            
            
    $arbo explode(".",$id);
            
    $NbArbo count($arbo)-1;
            
            
            switch (
    $NbArbo)
            {
                case 
    1:
                                
                    
    $sql "select * from SpeciesKingdom order by ScientificName";
                    
    $res sql::sql_query($sql);

                    
                    while (
    $ob mysql_fetch_object($res))
                    {
                        
    $ob->ScientificName ucwords(strtolower($ob->ScientificName));
                        
                        
    array_push($out, array(
                            
    'id'=>'n.1.'.$ob->Id,
                            
    'text'=>$ob->ScientificName,
                            
    'leaf'=>false
                        
    ));
                        
                    }
                break;
                
                case 
    2:
                {
                    
                    
    $sql "select * from SpeciesPhylum where IdSpeciesKingdom = '".$arbo[2]."' order by ScientificName";
                    
    $res sql::sql_query($sql);
                    while (
    $ob mysql_fetch_object($res))
                    {
                        
    array_push($out, array(
                            
    'id'=>$id.".".$ob->Id,
                            
    'text'=>$ob->ScientificName,
                            
    'leaf'=>false
                        
    ));
                    }
                }
                case 
    3:
                    
                    
    $sql "select * from SpeciesClass where IdSpeciesPhylum = '".$arbo[3]."' order by ScientificName";
                    
    $res sql::sql_query($sql);
                    
                    while (
    $ob mysql_fetch_object($res))
                    {
                        
    array_push($out, array(
                            
    'id'=>$id.".".$ob->Id,
                            
    'text'=>$ob->ScientificName,
                            
    'leaf'=>false
                        
    ));
                    }
                break;
                case 
    4:
                    
    $sql "select * from SpeciesOrder where IdSpeciesClass = '".$arbo[4]."' order by ScientificName";
                    
    $res sql::sql_query($sql);
                
                    while (
    $ob mysql_fetch_object($res))
                    {
                        
    array_push($out, array(
                            
    'id'=>$id.".".$ob->Id,
                            
    'text'=>$ob->ScientificName,
                            
    'leaf'=>false
                        
    ));
                    }
                case 
    5:
                
                    
    $sql "select * from SpeciesFamily where IdSpeciesOrder = '".$arbo[5]."' order by ScientificName";
                    
    $res sql::sql_query($sql);
                    
                    while (
    $ob mysql_fetch_object($res))
                    {
                        
    array_push($out, array(
                            
    'id'=>$id.".".$ob->Id,
                            
    'text'=>$ob->ScientificName,
                            
    'leaf'=>false
                        
    ));
                    }
                break;
                
                
                case 
    6:
                    
    $sql "select * from SpeciesGenus where IdSpeciesFamily = '".$arbo[6]."' order by ScientificName";
                    
    $res sql::sql_query($sql);
                    
                    while (
    $ob mysql_fetch_object($res))
                    {
                        
    array_push($out, array(
                            
    'id'=>$id.".".$ob->Id,
                            
    'text'=>$ob->ScientificName,
                            
    'leaf'=>false
                        
    ));
                    }
                break;
                
                case 
    7:
                
                    
    $sql "select * from SpeciesMain where IdSpeciesGenus = '".$arbo[7]."' order by ScientificName";
                    
    $res sql::sql_query($sql);
                    
                    while (
    $ob mysql_fetch_object($res))
                    {
                    
                        
    array_push($out, array(
                            
    'id'=>$id.".".$ob->Id,
                            
    'text'=>"<a href=\"onClick:ajax();\">".$ob->ScientificName."</a>",
                            
    'leaf'=>true
                        
    ));
                        
                    }
                break;
            }
            return 
    $out;
        }
    }


    ?>
    I tried different option that I can see in the documentation and the examples but I must say some difficulty to implement them.


    so I have 3 questions :

    I would use :
    preloadChilren (I hope it's when one user clic on a node we preload all this chidren and not all the children of my tree)

    createNode (I think it's this option)
    I want to display my tree at start in special configuration

    the last (the most important)

    How can I make a link with 'leaf'=>true (I think ext catch all the events before sent to navigator)
    Last edited by Aurélien LEQUOY; 24 Dec 2010 at 6:08 AM. Reason: solved

  2. #2
    Sencha - Community Support Team Condor's Avatar
    Join Date
    Mar 2007
    Location
    The Netherlands
    Posts
    24,246
    Vote Rating
    91
    Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of

      0  

    Default


    I'm not a PHP programmer. Can you post the data that your PHP page generates (e.g. using copy&paste from the Firebug Net tab)?

  3. #3
    Ext User
    Join Date
    Sep 2009
    Location
    Paris
    Posts
    7
    Vote Rating
    0
    Aurélien LEQUOY is on a distinguished road

      0  

    Exclamation no

    no


    No, the problem is not with PHP, I just put the code that I produce because the example was not enough for me.

    I replaced 'n112' by 'n.1.1.9.15.156.15478' like that i can make an explode/split on the string to know where I am on the tree, anyway the problem is not here.


    I am new with Ext js and not so good with js and my problem is how produce the code JS to do that :

    Create a node : to show the tree in a special configuration (like it's will be if i clic on one folder)

    Preload the data of each (folder) children when somebody click on a folder.


    Or if i can find an example with all this options.

  4. #4
    Ext User
    Join Date
    Sep 2009
    Location
    Paris
    Posts
    7
    Vote Rating
    0
    Aurélien LEQUOY is on a distinguished road

      0  

    Post


    I would be glad if somebody can help me, how to use preloadChilren & createNode ?

    thank you


    Aurélien LEQUOY

  5. #5
    Ext User
    Join Date
    Sep 2009
    Location
    Paris
    Posts
    7
    Vote Rating
    0
    Aurélien LEQUOY is on a distinguished road

      0  

    Default


    nobody have one idea about that ?

  6. #6
    Ext User
    Join Date
    Sep 2009
    Location
    Paris
    Posts
    7
    Vote Rating
    0
    Aurélien LEQUOY is on a distinguished road

      0  

    Default


    up

  7. #7
    Sencha - Community Support Team Condor's Avatar
    Join Date
    Mar 2007
    Location
    The Netherlands
    Posts
    24,246
    Vote Rating
    91
    Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of

      0  

    Default


    You didn't get an answer, because your question isn't clear enough.

    Try to explain (with more detail) what you are trying to accomplish...

  8. #8
    Ext User
    Join Date
    Sep 2009
    Location
    Paris
    Posts
    7
    Vote Rating
    0
    Aurélien LEQUOY is on a distinguished road

      0  

    Default


    I just wanna open the tree with a path.


    at start we have :

    1-- title 1
    |- item1
    |- item2
    |- item3
    |- item4
    ...

    I would have sothing like that



    1-- title 1
    |- item1
    | |- subitem1
    | |- text
    |- item2
    |- item3
    |- item4
    ...

  9. #9
    Sencha - Community Support Team Condor's Avatar
    Join Date
    Mar 2007
    Location
    The Netherlands
    Posts
    24,246
    Vote Rating
    91
    Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of

      0  

    Default


    Either have your server return the tree with that particular node expanded and with children or call expandPath to have the tree load and expand the required nodes.

  10. #10
    Ext User
    Join Date
    Sep 2009
    Location
    Paris
    Posts
    7
    Vote Rating
    0
    Aurélien LEQUOY is on a distinguished road

      0  

    Default


    finally I found the solution with the example :


    Code:
    tree.expandPath("/root/n3/n33");  
    //don't forget first "/"
    
    //or to focus one elemenet :
    tree.selectPath("/root/n3/n33");
    I think, it's will be better to propose one example to each function to know how to use them, most of time I have to read the code of framwork to know how to use this function.



    I would have one example with php, i mean by that one example of json to return to js, to know to implemente with many node.


    Now I am looking for the function to select automatically one item when the tree is expanded.

Thread Participants: 1