0
首先,我是一个extjs初学者。我无法使用ajax代理加载我的商店。EXT JS异步获取json数据并使用ajax代理加载商店
这是我的模型。
Ext.define('alertTemplates', {
extend: 'Ext.data.Model',
fields: ['text','config', {name: 'label', convert: function(v,record) {
if (Ext.isEmpty(record.data.text))
return nodeTemplate.apply(record.data.config);
else return record.data.text;
}}]
});
Attemping加载店
var store = Ext.create('Ext.data.TreeStore', {
model: 'alertTemplates',
proxy:{
type: 'ajax',
url: '/alfresco/service/alertTemplates.json?alf_ticket=' + user.authTicket,
reader:{
root:'children',
type: 'json'
},
autoLoad: true,
excludeContext: true,
method: 'GET',
params: {
nodeRef: currentProject.nodeRef
},
scope: this,
listeners: {
load: function(){
console.log('loaded');
}
}
}
});
store.load();
我知道我正确地检索数据。我以前使用过下面的代码,并且响应中包含我试图获取的json代码。我以正确的方式接近这个吗?
Jx.Utils.ajax({
url: '/alfresco/service/alertTemplates.json?alf_ticket=' + user.authTicket,
excludeContext: true,
method: 'GET',
params: {
nodeRef: currentProject.nodeRef
},
scope: this,
success: function (response)
{
var alertTemplates = response.json;
console.log(alertTemplates);
store.loadRawData(alertTemplates,true);
},
failure: console.log('failed')
});