Sencha touch 如何在存储中设置URL';谁的代理人?
我的代码有一个bug,但我不知道出了什么问题。 当点击NestedList的叶项目时,我尝试在存储中设置新的url。 这是我的商店:Sencha touch 如何在存储中设置URL';谁的代理人?,sencha-touch,extjs,sencha-touch-2,Sencha Touch,Extjs,Sencha Touch 2,我的代码有一个bug,但我不知道出了什么问题。 当点击NestedList的叶项目时,我尝试在存储中设置新的url。 这是我的商店: Ext.define('Application.store.DetailStore', { extend: 'Ext.data.Store', config: { model: 'Application.model.DetailModel', autoLoad :true, sorters: 'title', grouper :
Ext.define('Application.store.DetailStore', {
extend: 'Ext.data.Store',
config: {
model: 'Application.model.DetailModel',
autoLoad :true,
sorters: 'title',
grouper : function(record) {
return record.get('title')[0];
},
proxy: {
type: 'ajax',
url : '/data/data1.php',
reader: {
type: 'json',
rootProperty:'recipes'}
}
}
}))
这是我在NestedList中的leafitemtap的侦听器:
onLeafItemTap: function(nestedList, list, index, node, record, e) {
filter = record.get('text');
var detailCard = nestedList.getDetailCard();
Ext.getStore('Application.store.DetailStore').getProxy().setUrl('/data/data2.php');
Ext.getStore('Application.store.DetailStore').load()
}
在此之后,我无法点击叶子项目,细节卡也不会显示。
有人知道可能出了什么问题吗?下面我使用getMain方法在点击叶项目并加载存储时将detailCard推到列表顶部。我还假设您正在使用getMain作为ref在控制器中定义leaftItemTap逻辑 您还可以使用storeId而不是“Application.store.DetailStore”
如果您只想设置并加载存储,请重新阅读以下问题:Ext.getStore('Application.store.DetailStore').setProxy({type:'ajax',url:'/data/data2.php'})。load()而不是使用getProxy和seturl谢谢您的回复!但这并没有帮助,我仍然无法点击leaf项目。我测试了删除部分代码,当我在Ext.getStore('Application.store.DetailStore')之后写了一些东西时,它停止了工作。你能发布NestedList视图、模型和你从商店获取的JSON吗?很抱歉打扰你,我理解使用不同的url是不对的,我必须过滤我的商店。谢谢你的时间!
Ext.getStore('Application.store.DetailStore').setProxy({
type: 'ajax',
url: '/data/data2.php'
}).load({
callback: function(records, operations, success) {
if (success = true) {
this.getMain().push({
xtype: 'detailsCard',
data: record.getData()
})
} else {
Ext.Msg.alert('Error', 'Something went wrong!', Ext.emptyFn);
}
},
scope: this
});