-1

你好,Sencha建築師/觸摸嵌套列表問題

我正在與觸發2.4項目的sencha架構師合作。我有一個問題處理嵌套列表和樹店:

  • 這是我的店:

    Ext.define('App.store.Tree', { 
    extend: 'Ext.data.TreeStore', 
    
    requires: [ 
    'App.model.Servicios', 
    'Ext.data.proxy.Ajax', 
    'Ext.data.reader.Json', 
    'Ext.data.proxy.LocalStorage' 
    ], 
    
    
    config: { 
        model: 'App.model.Servicios', 
        storeId: 'Tree', 
        defaultRootProperty: 'items', 
        proxy: { 
         type: 'ajax', 
         type: 'localstorage', 
         reader: { 
          type: 'json' 
         } 
        } 
    } 
    

    });

(我試過用proxys和讀者的每個組合和錯誤是一樣的。)

  • 現在,這是我的模型:

    Ext.define('App.model.Servicios', { 
        extend: 'Ext.data.Model', 
    
    
        requires: [ 
        'Ext.data.Field' 
        ], 
    
    
        config: { 
        fields: [ 
        { 
        name: 'categoria', 
        type: 'string' 
        }, 
        { 
        name: 'nombre', 
        type: 'string' 
        }, 
        { 
        name: 'ubicacion', 
        type: 'string' 
        }, 
        { 
        name: 'datos', 
        type: 'string' 
        } 
        ] 
        } 
        }); 
    
  • 這是帶有嵌套列表的容器:

    Ext.define('App.view.ServiciosContainer', { 
        extend: 'Ext.Container', 
        alias: 'widget.servicioscontainer', 
    
    
        requires: [ 
        'Ext.Toolbar', 
        'Ext.Button', 
        'Ext.dataview.NestedList' 
        ], 
    
    
        config: { 
        height: '100%', 
        id: 'ServiciosContainer', 
        width: '100%', 
        layout: 'fit', 
        items: [ 
        { 
        xtype: 'toolbar', 
        docked: 'top', 
        items: [ 
        { 
        xtype: 'button', 
        id: 'serviciosContainerHome', 
        iconCls: 'list' 
        }, 
        { 
        xtype: 'button', 
        id: 'serviciosContainerBorrar', 
        iconCls: 'trash' 
        }, 
        { 
        xtype: 'button', 
        id: 'serviciosContainerAgregar', 
        iconCls: 'add' 
        } 
        ] 
        }, 
        { 
        xtype: 'nestedlist', 
        id: 'lstServicios', 
        displayField: 'nombre', 
        store: 'Tree' 
        } 
        ] 
        }, 
    
    
        }); 
    
    • Add按鈕執行以下操作:

      var data = { 
          items: [ 
           { 
           nombre: '1', 
           items: [{ 
             nombre: '1.1', 
             items: [{ 
               nombre: '1.1.1 last', 
               leaf: true 
             }, { 
           nombre: '1.1.2 last', 
           leaf: true 
           }] 
      }, { 
           nombre: '1.2 last', 
           leaf: true 
           }] 
      }, 
      { 
           nombre: '2', 
           items: [{ 
             nombre: '2.1 last', 
             leaf: true 
           }, { 
           nombre: '2.2 last', 
           leaf: true 
           }] 
      } 
      ] 
      }; 
      
      
      
      var servicios = Ext.getStore('TreeStore'); 
      servicios.add(data); 
      
  • 這是我的錯誤,當我嘗試將數據添加到商店:

    TypeError: null is not an object (evaluating 'children.length') 
    

請幫助!!!!我不知道在哪裏尋找錯誤,因爲我發現的所有例子與我的相同,並且他們沒有任何問題。

回答

0

我創建了一個使用我們的代碼的演示,它的工作正常。

我已經看到了很多的聯合國需要的代碼演示烏爾,就像你已經添加的代理商店等

但我清楚地看到你在#見STOREID它的「樹」,並期待在一個小的失誤Ext.getStore( 'TreeStore');

我希望你有我的觀點

感謝