0

I am looking for a tutorial / sourcecode for a sencha touch list with a model and a store. I am facing some issues with Sencha Touch 2.2.1.

Model:

Ext.define("DeviceAPIFramework.model.OfferModel", {
    extend: "Ext.data.Model",
    config: {
        fields: [
            { name: "description",  type: "string" },
            { name: "id", type: "string" }
        ]
    }
});

Store:

Ext.define("DeviceAPIFramework.model.OfferStore", {
    extend: "Ext.data.Store",
    config: {
        storeId: "offerStore",
        model:'DeviceAPIFramework.model.OfferModel'
    }
});

Controller:

offerStore.add({description: 'test', id: 'my id'});
Ext.ComponentQuery.query('#offersListHomeView')[0].update();

View:

Ext.require("DeviceAPIFramework.model.OfferStore");
var offerStore = Ext.create("DeviceAPIFramework.model.OfferStore");

Ext.define ........... 
{
    xtype: 'list',
    width: Ext.os.deviceType == 'Phone' ? null : 1200,
    height: Ext.os.deviceType == 'Phone' ? null : 350,
    title: 'test',
    itemId: 'offersListHomeView',
    store: offerStore,
    itemTpl: '{description} {id}'
}

Image:

Image of List

After executing the code from the controller, a new row gets appended, but also a weird undefined text on the upper left corner of my list. Any suggestions how to fix this issue?

I also don't like the variable offerStore outside the view. If I put it in the controller, the view is nagging.

4

1 回答 1

0

未定义来自这一行:

Ext.ComponentQuery.query('#offersListHomeView')[0].update();

更新被破坏(我写了它,因为我用旧的 Sencha Touch 版本开发过一次,这个更新是必要的)并将调用 setHtml(),因为我们没有传递任何参数它是设置“未定义”,这将显示在我们的看法。在新的煎茶版本中,您可以简单地删除这一行。

我还用控制器中的这段代码管理了全局存储问题:

launch: function() {
    this.offersStore = Ext.create('Ext.data.Store', {
        model: 'DeviceAPIFramework.model.OfferModel'
    });

    Ext.ComponentQuery.query('#offersListHomeView')[0].setStore(this.offersStore);
},
于 2013-07-09T17:48:20.850 回答