vinnybozz
13 May 2009, 7:59 AM
Hi, I am trying to convert an existing Store using an HttpProxy and JsonReader to a DirectStore ...
I just can't seem to make it work, here's a sample of my json store:
var store = new Ext.data.Store({
proxy: new Ext.data.HttpProxy({
method: 'POST',
url: 'ajax/get-users.php',
timeout: 120000
}),
reader: new Ext.data.JsonReader({
root: 'users',
totalProperty: 'totalCount'
},
[
{name: 'firstname', mapping: 'firstname'},
{name: 'lastname', mapping: 'lastname'},
{name: 'id', mapping: 'id'}
]
)
})
with server response:
{"totalCount":100,"users":[{"firstname":"Mo","lastname":"Smith","id":"9942418"},{"firstname":"Carlos","lastname"
:"Tran","id":"9954769"}]}
I am replacing it with:
var store = new Ext.data.DirectStore({
directFn: TestAction.getUsers,
paramsAsHash: true,
root: 'users',
totalProperty: 'totalCount',
idProperty: 'id',
fields: [
{name: 'firstname', mapping: 'firstname'},
{name: 'lastname', mapping: 'lastname'},
{name: 'id', mapping: 'id'}
]
});
which returns:
{"type":"rpc","tid":2,"action":"TestAction","method":"getUsers","result":{"totalCount":100,"users":[
{"firstname":"Mo","lastname":"Smith","id":"9942418"},{"firstname":"Carlos","lastname":"Tran","id":"9954769"
}]}}
It seems like the error occurs in the Reader, not being able to understand the data.
If anyone has any ideas it would be greatly appreciated.
Thx
Dan
I just can't seem to make it work, here's a sample of my json store:
var store = new Ext.data.Store({
proxy: new Ext.data.HttpProxy({
method: 'POST',
url: 'ajax/get-users.php',
timeout: 120000
}),
reader: new Ext.data.JsonReader({
root: 'users',
totalProperty: 'totalCount'
},
[
{name: 'firstname', mapping: 'firstname'},
{name: 'lastname', mapping: 'lastname'},
{name: 'id', mapping: 'id'}
]
)
})
with server response:
{"totalCount":100,"users":[{"firstname":"Mo","lastname":"Smith","id":"9942418"},{"firstname":"Carlos","lastname"
:"Tran","id":"9954769"}]}
I am replacing it with:
var store = new Ext.data.DirectStore({
directFn: TestAction.getUsers,
paramsAsHash: true,
root: 'users',
totalProperty: 'totalCount',
idProperty: 'id',
fields: [
{name: 'firstname', mapping: 'firstname'},
{name: 'lastname', mapping: 'lastname'},
{name: 'id', mapping: 'id'}
]
});
which returns:
{"type":"rpc","tid":2,"action":"TestAction","method":"getUsers","result":{"totalCount":100,"users":[
{"firstname":"Mo","lastname":"Smith","id":"9942418"},{"firstname":"Carlos","lastname":"Tran","id":"9954769"
}]}}
It seems like the error occurs in the Reader, not being able to understand the data.
If anyone has any ideas it would be greatly appreciated.
Thx
Dan