Extjs 动态加载存储数据并显示在列表中
我试图在列表视图中显示一组项目。服务器使单个文件中的所有项目都属于不同的子类别,并为每个子类别分配了类别ID。目前,我有一个存储可以导入所有的数据,如果没有应用过滤器。如果是,则显示属于该特定子类别的项目 我的店铺代码如下:Extjs 动态加载存储数据并显示在列表中,extjs,sencha-touch-2.1,Extjs,Sencha Touch 2.1,我试图在列表视图中显示一组项目。服务器使单个文件中的所有项目都属于不同的子类别,并为每个子类别分配了类别ID。目前,我有一个存储可以导入所有的数据,如果没有应用过滤器。如果是,则显示属于该特定子类别的项目 我的店铺代码如下: Ext.define('RestaurantGlobal.store.SubCategoryColumnsStoreNonVeg', { extend: 'Ext.data.Store', requires: [ 'Restaura
Ext.define('RestaurantGlobal.store.SubCategoryColumnsStoreNonVeg', {
extend: 'Ext.data.Store',
requires: [
'RestaurantGlobal.model.ItemColumns'
],
config: {
autoLoad: false,
model: 'RestaurantGlobal.model.ItemColumns',
storeId: 'SubCategoryColumnsStoreNonVeg',
proxy: {
type: 'ajax',
url: 'data/NonVegItemsColumnsStore.json',
reader: {
type: 'json',
rootProperty: 'Item'
}
},
filters: [{
property: 'SubCategory_id',
value: /0c9b01f6b3b2493b907a42e07010064800001/
}]
},
});
Ext.define('RestaurantGlobal.view.SubCategories', {
extend: 'Ext.navigation.View',
xtype: 'SubCategories',
config: {
layout: {
type: 'card'
},
items:[
{
xtype: 'container',
title: 'Category Name',
styleHtmlCls: 'maincontainer',
styleHtmlContent: true,
layout: {
type: 'vbox'
},
items: [
{
xtype: 'container',
title: 'Non-Veg',
margin: '0 10 0 10',
items: [
{
xtype: 'list',
id: 'nonVegList',
autoPaging: true,
height: '100%',
store: 'SubCategoryColumnsStoreVeg',
itemTpl: [
'<div>{Image}{Name}</div>'
],
},
]
},
{
xtype: 'container',
items: [
{
xtype: 'button',
cls: 'btn',
docked: 'bottom',
margin: '0 0 0 0',
text: 'Place Order'
}
]
}
]
}
]
}
});
我的应用程序有一个类别视图,显示类别列表,然后是一个子类别视图,其中包含属于所选类别的项目我想根据用户在上一个视图中选择的类别动态筛选从商店接收的数据,并将其显示在列表中。我的listview代码如下:
Ext.define('RestaurantGlobal.store.SubCategoryColumnsStoreNonVeg', {
extend: 'Ext.data.Store',
requires: [
'RestaurantGlobal.model.ItemColumns'
],
config: {
autoLoad: false,
model: 'RestaurantGlobal.model.ItemColumns',
storeId: 'SubCategoryColumnsStoreNonVeg',
proxy: {
type: 'ajax',
url: 'data/NonVegItemsColumnsStore.json',
reader: {
type: 'json',
rootProperty: 'Item'
}
},
filters: [{
property: 'SubCategory_id',
value: /0c9b01f6b3b2493b907a42e07010064800001/
}]
},
});
Ext.define('RestaurantGlobal.view.SubCategories', {
extend: 'Ext.navigation.View',
xtype: 'SubCategories',
config: {
layout: {
type: 'card'
},
items:[
{
xtype: 'container',
title: 'Category Name',
styleHtmlCls: 'maincontainer',
styleHtmlContent: true,
layout: {
type: 'vbox'
},
items: [
{
xtype: 'container',
title: 'Non-Veg',
margin: '0 10 0 10',
items: [
{
xtype: 'list',
id: 'nonVegList',
autoPaging: true,
height: '100%',
store: 'SubCategoryColumnsStoreVeg',
itemTpl: [
'<div>{Image}{Name}</div>'
],
},
]
},
{
xtype: 'container',
items: [
{
xtype: 'button',
cls: 'btn',
docked: 'bottom',
margin: '0 0 0 0',
text: 'Place Order'
}
]
}
]
}
]
}
});
在中,我添加了过滤器,重新加载了存储并将其与列表一起使用,但我得到一个错误,即“setStore”方法不可用。有人能帮我正确地动态实现过滤器吗 我认为问题在于获取列表时请将其更改为 var NVList=this.getNonVegList()