2017-01-04 12 views
1

Я работаю над созданием панели дерева в версии Extens 3.2.1, у меня есть код для создания дерева из XML-документа (tree.xml), который доступен на моем сервере который работает нормально.Создание панели дерева Extjs из xmlDocument, которая сохраняется в глобальной константе

Но я нахожусь в новой ситуации, где мой ответ сохраняется в глобальной переменной постоянной

Из запроса Ext.Ajax я получил ответ и сохраненным как следующий

global_const = response.responseXML; 

Мой вопрос, как я могу передать это global_const в treeloader?

Любая помощь и предложение благодарен

ответ

1

Я использовал JSON вместо XML

var Tree = Ext.tree; 

    var tree = new Tree.TreePanel('tree', { 
     animate:true, 
     enableDD:false, 
    loader: new Tree.TreeLoader(), // Note: no dataurl, register a TreeLoader to make use of createNode() 
    lines: true, 
    selModel: new Ext.tree.MultiSelectionModel(), 
     containerScroll: false 
    }); 


    // json data describing the tree 
    var json = 
[ 
{"text" : "Audi", "id" : 100, "leaf" : false, "cls" : "folder", "children" : [ 
    {"text" : "A3", "id" : 1000, "leaf" : false, "cls" : "folder", "children" : 
     [ {"text" : "Fuel Economy", "id" : "100000", "leaf" : true, "cls" : "file"}, 
      {"text" : "Invoice", "id" : "100001", "leaf" : true, "cls" : "file"}, 
      {"text" : "MSRP", "id" : "100002", "leaf" : true, "cls" : "file"}, 
      {"text" : "Options", "id" : "100003", "leaf" : true, "cls" : "file"}, 
      {"text" : "Specifications", "id" : "100004", "leaf" : true, "cls" : "file"} 
     ] 
    }, 
    {"text" : "TT", "id" : 1000, "leaf" : false, "cls" : "folder", "children" : 
     [ {"text" : "Fuel Economy", "id" : "100000", "leaf" : true, "cls" : "file"}, 
      {"text" : "Invoice", "id" : "100001", "leaf" : true, "cls" : "file"}, 
      {"text" : "MSRP", "id" : "100002", "leaf" : true, "cls" : "file"}, 
      {"text" : "Options", "id" : "100003", "leaf" : true, "cls" : "file"}, 
      {"text" : "Specifications", "id" : "100004", "leaf" : true, "cls" : "file"} 
     ] 
    }] 
}, 
{"text" : "Cadillac", "id" : 300, "leaf" : false, "cls" : "folder", "children" : [ 
    {"text" : "CTS", "id" : 1000, "leaf" : false, "cls" : "folder", "children" : 
     [ {"text" : "Fuel Economy", "id" : "100000", "leaf" : true, "cls" : "file"}, 
      {"text" : "Invoice", "id" : "100001", "leaf" : true, "cls" : "file"}, 
      {"text" : "MSRP", "id" : "100002", "leaf" : true, "cls" : "file"}, 
      {"text" : "Options", "id" : "100003", "leaf" : true, "cls" : "file"}, 
      {"text" : "Specifications", "id" : "100004", "leaf" : true, "cls" : "file"} 
     ] 
    }, 
    {"text" : "CTS-V", "id" : 1000, "leaf" : false, "cls" : "folder", "children" : 
     [ {"text" : "Fuel Economy", "id" : "100000", "leaf" : true, "cls" : "file"}, 
      {"text" : "Invoice", "id" : "100001", "leaf" : true, "cls" : "file"}, 
      {"text" : "MSRP", "id" : "100002", "leaf" : true, "cls" : "file"}, 
      {"text" : "Options", "id" : "100003", "leaf" : true, "cls" : "file"}, 
      {"text" : "Specifications", "id" : "100004", "leaf" : true, "cls" : "file"} 
     ] 
    }] 
} 

]; 

    // set the root node 
    var root = new Tree.AsyncTreeNode({ 
     text: 'Autos', 
     draggable:false, 
     id:'source', 
     children: json 
    }); 

    tree.setRootNode(root); 

    tree.render(); 
    root.expand();