danellison
28 Jan 2010, 2:43 PM
Hi folks. I have been working a bit with Ext.Direct of late. I love the easy access to PHP methods on the backend. Initially I always used a JsonStore with an Ext.Direct call to load the data via a callback handler as shown in the code block below:
var store = new Ext.data.JsonStore({
fields: [ 'projects_projectid'],
data: []
});
function fillMyData(resp, e) {
var json = Ext.util.JSON.decode(resp);
if(json.success) {
store.loadData(json.data);
} else {
alert(json.error);
}
}
ICCI.ICCI.getMyProjects(fillMyData, this);
This method works fine but soon you are writing the same handler code over and over.... So I decided to dive into the DirectStore to see if I could get around the callback overhead. After hours of attempting to successfully load data into an Ext.data.DirectStore, reading every post I could find and tracing into ext-all-debug I have turned to the forum for an answer. My Ext.Direct store declaration is as follows:
var store = new Ext.data.DirectStore({
autoLoad: true,
api: {
read: ICCI.ICCI.getMyProjects
},
paramsAsHash: false,
fields: ['projects_projectid'],
root: 'data',
idProperty: 'projects_projectid',
totalProperty: 'total',
successProperty: 'success',
messageProperty: 'error',
listeners: {
'exception': function(proxy, type, action, options, res, arg) {
alert("exception: "+arg);
},
'load': function(proxy, type, action, options, res, arg) {
alert("load: "+arg);
}
}
});
With a DirectStore I get an exception event in ext-all.js: root is undefined. Clearly, root is defined in my store declaration. I cannot find a solution. Anybody see anything wrong with my store definition? Anybody shed any light on the problem?
I found an override that didn't help. Ideas? inquiring mind is worn out trying but I still need to know.
Many thanks,
Dan
var store = new Ext.data.JsonStore({
fields: [ 'projects_projectid'],
data: []
});
function fillMyData(resp, e) {
var json = Ext.util.JSON.decode(resp);
if(json.success) {
store.loadData(json.data);
} else {
alert(json.error);
}
}
ICCI.ICCI.getMyProjects(fillMyData, this);
This method works fine but soon you are writing the same handler code over and over.... So I decided to dive into the DirectStore to see if I could get around the callback overhead. After hours of attempting to successfully load data into an Ext.data.DirectStore, reading every post I could find and tracing into ext-all-debug I have turned to the forum for an answer. My Ext.Direct store declaration is as follows:
var store = new Ext.data.DirectStore({
autoLoad: true,
api: {
read: ICCI.ICCI.getMyProjects
},
paramsAsHash: false,
fields: ['projects_projectid'],
root: 'data',
idProperty: 'projects_projectid',
totalProperty: 'total',
successProperty: 'success',
messageProperty: 'error',
listeners: {
'exception': function(proxy, type, action, options, res, arg) {
alert("exception: "+arg);
},
'load': function(proxy, type, action, options, res, arg) {
alert("load: "+arg);
}
}
});
With a DirectStore I get an exception event in ext-all.js: root is undefined. Clearly, root is defined in my store declaration. I cannot find a solution. Anybody see anything wrong with my store definition? Anybody shed any light on the problem?
I found an override that didn't help. Ideas? inquiring mind is worn out trying but I still need to know.
Many thanks,
Dan