2012-12-12 296 views
0

商店对象通过ajax请求动态加载。在控制台中进行调试时,我可以看到商店对象被填充记录,但是列表为空。Sencha Touch 2.空列表

代码:

口的视图

Ext.define('sample.views.Viewport', { 
    extend: 'Ext.tab.Panel', 

    title: 'Hello world!', 

    xtype: 'viewport', 

    config: { 
     fullscreen: true, 

     tabBar: { 
      docked: 'bottom', 
     }, 

     items: [ 
      { xclass: 'sample.views.wares.lists.Popular' }, 
     ] 
    } 
}); 

NavigationView视图

Ext.define('sample.view.wares.lists.Popular', { 
    extend: 'Ext.NavigationView', 

    xtype: 'Popular', 

    config: {  
     iconCls: 'home', 
     title: 'Pop. prekės', 

     items: [ 
      { 
       xtype: 'wares',               
      } 
     ] 
    } 
}); 

列表视图

Ext.define('sample.views.wares.lists.List', { 
    extend: 'Ext.List', 

    xtype: 'wares', 

    config: { 
     store: 'Wares', 
     itemTpl: '{Name}' 
    }, 

    initialize: function() { 
     this.config.title = sample.app.title; 
    } 
});  

的记录存储对象这是动态通过Ajax重新加载寻求。

Ext.define('sample.store.Wares', { 
    extend: 'Ext.data.Store', 

    config: { 
     model: "sample.models.WaresListItem" 
    } 
}); 

Result in Ripple emulator

回答

1
initialize: function() { 
    this.config.title = sample.app.title; 
    this.callParent(); 
} 

“this.callParent()”是非常重要的,如果你有初始化函数,因为它调用父(在你的情况“Ext.dataview.List”),并要求它做的某些默认事情必须要List来构造。这与在java中从构造函数调用super类似。

如果你可以移动到这个声明块

this.config.title = sample.app.title; 

,并像这样做

config: { 
    store: 'Wares', 
    itemTpl: '{Name}', 
    title: sample.app.title 
}, 

你就不需要仍然初始化块共

2

大多数的时候,你看不到的内部组件,那是因为你还没有定义其容器的布局。

尝试将布局添加到您的导航视图的配置如下图所示:

​​

希望这有助于

另见:RDougan的答案在这里:在官方How do I make a dataview.list visible in Sencha Touch 2?

+0

相同的结果。布局配置不影响显示列表。 –

0

几次审查示例应用程序通过在initialize函数中调用callParent函数解决了文档和问题。不知道为什么。

initialize: function() { 
    this.config.title = sample.app.title; 
    this.callParent(); 
}