2016-12-06 5 views
1

Я мог видеть загрузку дочерних узлов в первом и, как ни странно, не во втором? Любые мыслиExtjs Тройные дочерние узлы не загружаются

Fiddle здесь

https://fiddle.sencha.com/#view/editor&fiddle/1lss

Ext.application({ 
    name: 'Fiddle', 

    launch: function() { 
     Ext.define('ComplexTree', { 
      extend: 'Ext.data.TreeStore', 
      alias: 'store.complextree', 
      storeId: 'ComplexTree', 
      root: { 
       expanded: true, 
       children: [{ 
        text: 'test', 
        leaf: true 
       }, { 
        text: 'test2', 
        expanded: true, 
        children: [{ 
         text: 'test21', 
         leaf: true 
        }, { 
         text: 'test22', 
         leaf: true 
        }] 
       }, { 
        text: 'test3', 
        leaf: true 
       }] 
      } 
     }); 

     Ext.create('Ext.tree.Panel', { 
      title: 'Complex Tree', 
      width: 200, 
      height: 200, 
      store: Ext.create('ComplexTree'), 
      rootVisible: false, 
      renderTo: Ext.getBody() 
     }); 

     Ext.create('Ext.tree.Panel', { 
      title: 'Complex Tree', 
      width: 200, 
      height: 200, 
      store: Ext.create('ComplexTree'), 
      rootVisible: false, 
      renderTo: Ext.getBody() 
     }); 
    } 
}); 
+1

Интересно. Вы пытались спросить на [Sencha Forum] (https://www.sencha.com/forum/)? –

+0

Да, довольно интересно ... нет Я havent –

ответ

2

Поскольку они делят набор данных (объектные ссылки). Измените свой магазин следующим образом:

Ext.define('ComplexTree', { 
    extend: 'Ext.data.TreeStore', 
    alias: 'store.complextree', 

    constructor: function (config) { 
     config = config || {}; 
     config.root = { 
      expanded: true, 
      children: [{ 
       text: 'test', 
       leaf: true 
      }, { 
       text: 'test2', 
       expanded: true, 
       children: [{ 
        text: 'test21', 
        leaf: true 
       }, { 
        text: 'test22', 
        leaf: true 
       }] 
      }, { 
       text: 'test3', 
       leaf: true 
      }] 
     }; 
     this.callParent([config]); 
    } 
}); 
+0

Это работало потрясающе, не могли бы вы сообщить мне, что делает этот config.root и вызвать родителя? –

+1

Он устанавливает корневое свойство в config, затем вызывает родительский конструктор, передавая конфигурацию. –

Смежные вопросы