Hybrid View

  1. #1
    Sencha User
    Join Date
    Jul 2008
    Posts
    53
    Vote Rating
    0
    jash is on a distinguished road

      0  

    Default HELP !!: Store not loading/parsing data from direct response

    HELP !!: Store not loading/parsing data from direct response


    Hi

    I have a model:

    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,
                        
    createAffiliation_FaxNumber.create,
                        
    updateAffiliation_FaxNumber.update,
                        
    destroyAffiliation_FaxNumber.destroy
                      
    }
                }
        
    }); 
    if I create a store:

    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

  2. #2
    Sencha - Ext JS Dev Team evant's Avatar
    Join Date
    Apr 2007
    Location
    Sydney, Australia
    Posts
    16,942
    Vote Rating
    636
    evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute

      0  

    Default


    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.html
    Evan Trimboli
    Sencha Developer
    Twitter - @evantrimboli
    Don't be afraid of the source code!

  3. #3
    Sencha User
    Join Date
    Jul 2008
    Posts
    53
    Vote Rating
    0
    jash is on a distinguished road

      0  

    Default


    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. #4
    Sencha User
    Join Date
    Dec 2012
    Posts
    13
    Vote Rating
    0
    JackThor is on a distinguished road

      0  

    Default


    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.

  5. #5

Thread Participants: 2

Tags for this Thread