gpt4 book ai didi

store - Sencha Touch DataView 不显示商店中的项目

转载 作者:行者123 更新时间:2023-12-01 04:06:21 26 4
gpt4 key购买 nike

我正在使用 Sencha touch 2。我从现有的 js 对象中存储了该负载:

Ext.define('majestic.store.Dataset', {
extend : 'Ext.data.Store',

requires : [
'majestic.model.Dataset',
'majestic.util.config.ConfigurationManager'
],
config : {
model : 'majestic.model.Dataset',
type: 'memory',
reader: 'json',
autoLoad : true,
proxy: {
type: 'memory',
reader: {
type: 'json',
rootProperty : 'datasets'
}
}

},
constructor: function(config) {
this.callParent(arguments);
this.applyData(majestic.util.config.ConfigurationManager.getConfig());
}

});

模型:
Ext.define('majestic.model.Dataset', {
extend : 'Ext.data.Model',

config : {
fields : [
'title'
],

associations: [
{type: 'hasMany', model: 'Layer', name: 'layers'}
]

}
});

并查看:
Ext.define('majestic.view.LayerList', {
requires: ['majestic.store.Dataset'],
extend: 'Ext.dataview.List',
config:{
store: 'Dataset',
itemTpl: '<div>{id} is {title}</div>',
itemSelector: "div"
}
});

看了之后 Data view in Sencha touch我已经添加了 autoLoad 和 itemSelector,仍然没有运气。

虽然运行
new majestic.store.Dataset().each(function(i) {console.log(i)}); 

输出具有填充数据属性的对象列表。

更新

我同意@fbrandel 第一个选项是它应该如何工作,但在阅读 ST 源代码后,我发现 dataview 的 store 参数被解释为:
  • 存储对象
  • json 存储符号,如第一个示例 here
  • 可以使用 StoreManager.lookup 解析的已创建商店的名称

  • 所以我结束了:
  • 离开 store:'Dataset'在查看
  • 添加 storeId : "Dataset"存储,所以可以通过StoreManager解决
  • 添加 stores: ['Dataset']这导致了 majestic.store.Dataset 的创建并在 StoreManager 中注册

  • 附言也可以使用 this.setStore(new majestic.store.Dataset()) 来完成在 initialization GridView 的方法,但我更喜欢可能的声明方式

    最佳答案

    以下是一些建议:

  • 尝试将商店设置为 'majestic.store.Dataset' 而不仅仅是 Dataset
  • 将商店依赖项添加到您的 app.js 中,如下所示:
    Ext.application({
    name: 'majestic',
    stores: ['Dataset'],

    launch: function() {
    ...
    }
    });
  • 不是将字符串传递给 store 属性,而是传递一个实例:
    store: Ext.create('majestic.store.Dataset')

  • 选项#1 似乎是它应该如何工作的最明显的方式。如果没有,这可能是 ST2 中的错误。

    关于store - Sencha Touch DataView 不显示商店中的项目,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9139246/

    26 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com