1. #1
    Sencha User
    Join Date
    Mar 2012
    Posts
    1
    Vote Rating
    0
    iratxeof is on a distinguished road

      0  

    Default Tree node with geoext action

    Tree node with geoext action


    Hi all!! I want to create a TreePanel composed by diferente tree nodes, each of those related with a geoext action.
    I have the layers filtered in an array, and I have construct another array with the specification of each node.


    /** Create all tree nodes **/
    function createNodes(){
    treeConfig = new Array();

    for(var k=0; k < arrayCapasLeyenda.length; k++) {
    if ((arrayCapasLeyenda[k].leyendaMinScale == 0.0 && arrayCapasLeyenda[k].leyendaMaxScale == 0.0)
    || (map.getScale() >= arrayCapasLeyenda[k].leyendaMaxScale && map.getScale() <= arrayCapasLeyenda[k].leyendaMinScale)) {
    if (arrayCapasLeyenda[k].icon != null && arrayCapasLeyenda[k].icon != undefined) {
    treeConfig[treeConfig.length] = { nodeType: 'gx_layer', layer: arrayCapasLeyenda[k].name, text: arrayCapasLeyenda[k].name, icon: '../imgs/' + arrayCapasLeyenda[k].icon };
    }
    else {
    treeConfig[treeConfig.length] = { nodeType: 'gx_layer', layer: arrayCapasLeyenda[k].name, text: arrayCapasLeyenda[k].name, icon: '../imgs/visores/blank.gif' };
    }
    }
    }
    return treeConfig;
    }

    How can assign an action to each node? Thanks in advance!!!!


    function createTreePanel() {
    MyTreeNodeUI = Ext.extend(GeoExt.tree.LayerNodeUI, { actions: [{
    action: "delete",
    qtip: "delete"
    }] });


    //Crear nodos

    var treeConfig = createNodes();

    //Árbol
    tree = new Ext.tree.TreePanel({
    border: true,
    autoScroll: true,
    enableDD: false,
    animate:true,
    lines: false,
    split:true,
    rootVisible: false,
    loader: new Ext.tree.TreeLoader({
    applyLoader: false,
    uiProviders: {
    'ui': MyTreeNodeUI
    },
    baseAttrs: {
    uiProvider: "ui"
    }
    }),
    plugins: [ {
    ptype: "gx_treenodeactions",
    listeners: { action: onAction }
    }],
    listeners: {
    'checkchange': function(node) {
    if (node.layer.options.excluyente) {
    for (var i=0; i<map.layers.length; i++) {
    [I] if ((map.layers[i].options.excluyente == true) && (map.layers.name.toUpperCase() != node.layer.name.toUpperCase())) {
    [I] map.layers.setVisibility(!node.layer.visibility);
    break;
    }
    }

    }
    }
    }
    });

    var root = new Ext.tree.AsyncTreeNode({
    draggable:false,
    children: treeConfig
    });

    tree.setRootNode(root);
    }

    function onAction(node, action, evt) {
    var layer = node.layer;
    switch(action) {
    case "delete":
    layer.destroy();
    break;
    }
    };

  2. #2
    Sencha User PhiLho's Avatar
    Join Date
    Nov 2011
    Location
    Near Paris, France
    Posts
    139
    Vote Rating
    1
    PhiLho is on a distinguished road

      0  

    Default


    When I see JavaScript code in a GXT 3 forum, particularly with stuff like Ext.tree, I am suspecting the message is in the wrong forum. GXT is a framework for using Java to code for the Web...

Thread Participants: 1