如何使用存储中的数据填充视图

How to populate a View with data from the Store?

本文关键字:数据 填充 视图 何使用 存储      更新时间:2023-09-26

在Sencha Touch 2中,控制器中有此代码。主要目的是用存储中的数据填充视图。目前我使用setRecord没有成功。

你能用一个代码样本给我指明正确的方向吗?Thnks

// Load data in the model after a user is successfully authenticated
    populateViewsAfterLogIn: function (){
        var me = this;
        var storeEvents2 =  Ext.getStore('Events2');
        storeEvents2.load();
        storeEvents2.sync();
        var myDashBoardView = me.getNavigViewTimetable();
        myDashBoardView.setRecord(storeEvents2);

    },

因此,我想重申一下,您希望使用setStore(...)而不是setRecord(...):

myDashBoardView.setStore(storeEvents2);

然后在您的视图中,您可以使用:this.getStore();访问商店,或者以这种方式循环浏览商店记录:

this.getStore().each(function(item, index, length) {
  // do something with the record (item)
});

祝你好运,让我们知道它是否有效。