Results 1 to 4 of 4

Thread: ExtJS4 TreePanel?????????selectPath??????????

  1. #1
    Sencha User
    Join Date
    Oct 2012
    Posts
    2
    Vote Rating
    0
      0  

    Default ExtJS4 TreePanel?????????selectPath??????????

    ??????

    ExtJS 2.? ???????????????????????
    ExtJS4.???????????TreePanel?????????selectPath??????????
    ????????????????????????

    ??????????node?selectPath???????
    ???????????????????



    ??????????????????????????


    ?????????????????


    Ext.define('TreeData', {
    extend: 'Ext.data.Model',
    fields: [
    {name:"id"},
    {name:"text"},
    {name:"leaf"},
    {name:"iconCls"},
    {name:"base_cd"},
    {name:"sc_kbn"},
    {name: 'disabled', type:'bool', defaultValue:false}
    ]
    });

    var store = Ext.create('Ext.data.TreeStore', {
    model: 'TreeData',
    proxy: {
    type: 'ajax',
    url: './abcde.php',
    actionMethods: {
    create: 'POST',
    read: 'POST',
    update: 'POST',
    destroy: 'POST'
    }
    },
    root: {
    text: 'Root',
    id: 'rootNode',
    expanded: false
    }
    });

    // ??????????????
    var treePanelObj = new Ext.tree.Panel({
    renderTo: 'tree',
    id: 'tree',
    animate: true,
    autoScroll: true,
    useArrows: true,
    rootVisible: false,
    border: false,
    width: 2000,
    store: store,
    plugins: [{ptype:'nodedisabled'}]
    });


    // node??
    treePanelObj.expandPath(data.treePath);
    treePanelObj.selectPath(data.treePath);




    ??????ExtJS 4.0.7

  2. #2
    Sencha User
    Join Date
    Mar 2010
    Posts
    34
    Vote Rating
    0
      0  

    Default

    ???????????????????????
    ????????ext-4.0.7-gpl/examples/tree/reorder.html????
    ???????????????????????????????

    ???????examples/tree/reorder.js
    PHP Code:
    var tree Ext.create('Ext.tree.Panel', {
        
    storestore,
        
    viewConfig: {
            
    plugins: {
                
    ptype'treeviewdragdrop'
            
    }
        },
        
    renderTo'tree-div',
        
    height300,
        
    width250,
        
    title'Files',
        
    useArrowstrue,
        
    dockedItems: [{
            
    xtype'toolbar',
            
    items: [{
                
    text'Expand All',
                
    handler: function(){
                    
    //??????????
                    //tree.expandAll();
                    
    tree.selectPath('/Ext JS/app','text',null,function(a,b){console.log(a);console.log(b);});
                }
            }, {
                
    text'Collapse All',
                
    handler: function(){
                    
    tree.collapseAll();
                }
            }]
        }]
    }); 
    ?????????'/Ext JS/app' ?????????????
    ?2???'text'?????????????????????
    (??????ID???ID?'/'???????????3?????????????????????)

    ????????"/"????????
    ????????"/"????(??????)????

    ???"app"????????????????????"app"?????????????????????????
    ???????????????????????????????


    ?????????????????????????????????OK??????
    PHP Code:
    tree.getSelectionModel().clearSelections();
    tree.selectPath('/Ext JS/app','text',null,function(a,b){console.log(a);console.log(b);}); 
    ????????

  3. #3
    Sencha User
    Join Date
    Oct 2012
    Posts
    2
    Vote Rating
    0
      0  

    Default ???????

    ????????????????????

    ????????????????????????????????


    ????????????????ExtJS????????
    ??????????????????????????
    ?????????


    ????????????????????
    ????????????????????????
    ????????????????????

  4. #4
    Sencha User
    Join Date
    Mar 2010
    Posts
    34
    Vote Rating
    0
      0  

    Default

    ????????????????????????????????
    ?????????????????
    ???????????????????????????


    ?????????????????????????????????????????
    ???????????????
    (??????????????????????????????)

    View (ViewPort)?
    PHP Code:
    Ext.define('Sample.view.Viewport', {
        
    extend'Ext.container.Viewport',
        
    alias'widget.Sample-viewport',

        
    id'mainView',
        
    layout'auto',
        
    autoScrolltrue,
        
    config: {
            
    buttonSamplenull,
            
    treePanelObjnull
        
    },

        
    initComponent: function() {

            var 
    me this;
            
    console.log(Ext.getClassName(me) + '#initComponent');

            
    me.setButtonSample(Ext.create('Ext.button.Button',{
                
    renderTo'buttonSample',
                
    text'???',
                
    name'sample',
                
    action'sampleButtonAction'
            
    }));

            
    Ext.define('TreeData', {
                
    extend 'Ext.data.Model',
                
    fields : [ {
                    
    name "id"
                
    }, {
                    
    name "text"
                
    }, {
                    
    name "leaf"
                
    }, {
                    
    name "iconCls"
                
    }, {
                    
    name "base_cd"
                
    }, {
                    
    name "sc_kbn"
                
    }, {
                    
    name 'disabled',
                    
    type 'bool',
                    
    defaultValue false
                
    } ]
            });

            var 
    store Ext.create('Ext.data.TreeStore', {
                
    model 'TreeData',
                
    proxy : {
                    
    type 'ajax',
                    
    url './a.json',
                    
    actionMethods : {
                        
    create 'POST',
                        
    read 'POST',
                        
    update 'POST',
                        
    destroy 'POST'
                    
    }
                },
                
    root : {
                    
    text 'Root',
                    
    id 'rootNode',
                    
    expanded false
                
    }
            });

            
    // ??????????????
            
    var treePanelObj = new Ext.tree.Panel({
                
    renderTo 'tree',
                
    id 'tree',
                
    animate true,
                
    autoScroll true,
                
    useArrows true,
                
    rootVisible false,
                
    border false,
                
    height50,
    //            width: 2000,
                
    store store,
    //            plugins : [ {
    //                ptype : 'nodedisabled'
    //            } ]
            
    });

            
    me.setTreePanelObj(treePanelObj);

            
    // ????????????(??????????)
            
    me.callParent(arguments);
            
    // config ? getter?setter ???????
            
    me.initConfig(arguments);
        },
        
        
    selectNode: function(){
            var 
    me this;
            
    console.log(Ext.getClassName(me) + '#afterInit');
            
    me.getTreePanelObj().getSelectionModel().clearSelections();
            
    me.getTreePanelObj().selectPath('/rootNode/a/c',null,null,function(a,b){console.log(a);console.log(b);});
        },
    }); 
    Control?
    PHP Code:
    Ext.define('Sample.controller.Control', {
        
    extend'Ext.app.Controller',
        
    refs: [
            {
    ref'viewport'selector'Sample-viewport'}
        ],

        
    init: function(app) {
            var 
    me this;
            
    console.log(Ext.getClassName(me) + '#init');

            
    me.control({
                
    'button[action=sampleButtonAction]': {
                    
    clickme.selectNodeAction
                
    }
            });
            
    // ????????????(??????????)
            
    me.callParent(arguments);
        },

        
    selectNodeAction: function(buttonObjecteventeOpts){
            var 
    me this;
            
    console.log(Ext.getClassName(me) + '#selectNodeAction');
            
    me.getViewport().selectNode();
        },
    }); 

    HTML(Form?????2?????????????)?
    PHP Code:
    <div id="buttonSample"></div>
    <
    div id="tree"></div

    JSON(??????????????????)?
    PHP Code:
    {id:"rootNode",
    "children": [
        {
            
    id:"a",
            
    text:"a",
            
    leaf:"a",
            
    iconCls:"a",
            
    base_cd:"a",
            
    sc_kbn:"a",
            
    disabled:"false",
            
    children:[{
                
    id:"b",
                
    text:"b",
                
    leaf:"b",
                
    iconCls:"b",
                
    base_cd:"b",
                
    sc_kbn:"b",
                
    disabled:"false"
            
    }, {
                
    id:"c",
                
    text:"c",
                
    leaf:"c",
                
    iconCls:"c",
                
    base_cd:"c",
                
    sc_kbn:"c",
                
    disabled:"false"
            
    }, {
                
    id:"d",
                
    text:"d",
                
    leaf:"d",
                
    iconCls:"d",
                
    base_cd:"d",
                
    sc_kbn:"d",
                
    disabled:"false"
            
    }, {
                
    id:"e",
                
    text:"e",
                
    leaf:"e",
                
    iconCls:"e",
                
    base_cd:"e",
                
    sc_kbn:"e",
                
    disabled:"false"
            
    }, {
                
    id:"f",
                
    text:"f",
                
    leaf:"f",
                
    iconCls:"f",
                
    base_cd:"f",
                
    sc_kbn:"f",
                
    disabled:"false"
            
    }, {
                
    id:"g",
                
    text:"g",
                
    leaf:"g",
                
    iconCls:"g",
                
    base_cd:"g",
                
    sc_kbn:"g",
                
    disabled:"false"
            
    }]
        }
    ]} 

Posting Permissions

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