Firstly, I am an extjs beginner. I am having trouble loading my store using an ajax proxy.
Here is my model.
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 to load the store
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();
I know I am properly retrieving the data. I used the code below before and the response contained the json code I am trying to get. Am I approaching this the right way?
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')
});