Hybrid View
-
7 Jun 2011 4:40 AM #1
HELP !!: Store not loading/parsing data from direct response
HELP !!: Store not loading/parsing data from direct response
Hi
I have a model:
if I create a store:PHP Code:Ext.define('Affiliation.model.FaxNumber', {
extend : 'Ext.data.Model',
idProperty : 'Id',
fields:[
{name : 'Id', type: 'int'},
{name : 'CountryCode', type : 'string'},
{name : 'AreaCode', type : 'string'},
{name : 'SubscriberNumber', type : 'string'}
],
proxy:{ type:'direct',
totalProperty : 'total',
successProperty : 'success',
reader : {type : 'json', root : 'data'},
writer : {type : 'json', encode : false},
paramsAsHash:true,
api : { read:Affiliation_FaxNumber.read,
create: Affiliation_FaxNumber.create,
update: Affiliation_FaxNumber.update,
destroy: Affiliation_FaxNumber.destroy
}
}
});
var FaxNumbers = Ext.create('Ext.data.Store',{model : 'Affiliation.model.FaxNumber',autoLoad : true , filters: [{property : 'AffiliationId', value : 3}]
It sends out :
{"action":"Affiliation_FaxNumber","method":"read","data":[{"page":1,"start":0,"limit":25,"filter":[{"property":"AffiliationId","value":3}]}],"type":"rpc","tid":6}
which is fine
the server returns (Faxnumber changed for this post)
{"tid": 6, "action": "Affiliation_FaxNumber", "type": "rpc", "method": "read", "result": {"total": 1, "data": [{"AreaCode": "(0)223", "SubscriberNumber": "<REMOVED>", "Id": 3, "CountryCode": "+31"}], "success": true}}
then I do a FaxNumer.each(......) which does not do anything, so I typed FaxNumer in the console (Safari) and open up the Object.
Just to see that the Data array contains NO data.
(the data below is from the console so the small Arrows for object expansion are gone)
Note the totalCount : 1 !!
if I do the same but init the sore with autoLoad : false, totalCount is NOT there, but after a FaxNumbers.Load() totalCount gets 1
ject
autoLoad: true
data: Object
allowFunctions: false
events: Object
getKey: function (record) {
items: Array (0)
keys: Array (0)
length: 0
map: Object
sorters: Object
__proto__: Object
events: Object
eventsSuspended: false
filters: Object
groupers: Object
loading: false
model: function () {
modelDefaults: Object
proxy: Object
removed: Array (0)
snapshot: Object
sorters: Object
totalCount: 1
__proto__: Object
-
7 Jun 2011 6:05 AM #2
totalProperty and successProperty aren't valid proxy options, they belong on the reader, not that it should be causing any problem.
I'd suggest you look at the example:
http://dev.sencha.com/deploy/ext-4.0...rect-grid.htmlEvan Trimboli
Sencha Developer
Twitter - @evantrimboli
Don't be afraid of the source code!
-
7 Jun 2011 6:28 AM #3
Thanks but not much of a help,
I can still not figure out what type : 'direct' really means. Ext.data.DirectStore seems incapable of full CRUD and keeps moaning about directFN and I need to specify my proxies on the model. (long story, wrong place)
There are no CRUD examples, and again, and again, and again, and again, and again .......
the 4.0 docs on Direct/data/models/stores are confusing or possibly incorrect and FAR from clear.
and models/stores behave really weird when using Direct CRUD.
Everytime I ask a question, you guys respond look at that grid example. which uses DirectFN
Get me a working store/model/direct/CRUD example please, please.
I have allready spent 200 hours of experimenting with properties to get a store working over direct getting all kinds of stupid and weird errors. The Docs are extremely incomplete when it goes about details.
So there is the IdProperty on a Model, I have still not seen anything change to whatever you set it. I thought it was to set which property on the model is the "id" of the record. but if I set it, the whole lot of code which is building the request to the server ends up sending "id" period.
I got the store loading now, but now <modelInstance>.load is undefined again.
Thanks for the effort though
Jash
(Is there really nobody capable of helping me with Direct/crud/stores and models ?)
-
4 Jan 2013 1:30 PM #4
This might or might not help, but here is a working example using a direct proxy, but it uses a sales force database. Notice how at the end you have to provide some proxy extension for Sencha and the server to talk.
-
4 Jan 2013 1:32 PM #5


Reply With Quote