1. #1
    Sencha User
    Join Date
    Feb 2012
    Posts
    16
    Vote Rating
    0
    vtu is on a distinguished road

      0  

    Default Answered: Dynamic Store using metadata Null model and fields

    Answered: Dynamic Store using metadata Null model and fields


    Hi I'm having an issue with my store using metadata. I get null values for model and fields when i do store.getFields() or store.getModel(). The store contains the relevant data in this case the users but the model and fields of the store is null. I would like to know what I'm missing in order to populate the fields and model. Thanks
    I'm using json similar to the following for testing.

    {"count":1,
    "ok":true,
    "msg":"Users found",
    "users":[{"userId":123,"name":"Ed Spencer","email":"ed@sencha.com"}],
    "metaData":{"idProperty":'userId',"rootProperty":"users","totalProperty":'count',"successProperty":'ok',"messageProperty":'msg', "fields":[ { "name": "userId", "type": "int" }, { "name": "name", "type": "string" }, { "name": "email", "type": "string" }
    ] }
    }


    My ModelExt.define('DST.model.DynamicModel', {
    extend: 'Ext.data.Model',
    config: {
    fields: []
    }
    });

    My Store
    Ext.define('DST.store.DynamicStore', {
    extend: 'Ext.data.Store',
    config:{
    model: 'DST.model.DynamicModel',
    proxy: {
    type: 'ajax',
    url: 'app/data/dynamictest.json',
    reader: {
    type: 'json',
    idProperty: 'id',
    rootProperty: 'root',
    totalProperty: 'total',
    successProperty: 'success',
    messageProperty: 'message'
    },
    timeout: 10000
    }
    }
    });



    Last edited by vtu; 6 Sep 2012 at 8:53 AM. Reason: make it more readable

  2. You would need to extend the reader and capture when it decodes the response so you can create your model.

  3. #2
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    St. Louis, MO
    Posts
    33,641
    Vote Rating
    434
    Answers
    3107
    mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of

      0  

    Default


    You would need to extend the reader and capture when it decodes the response so you can create your model.
    Mitchell Simoens @SenchaMitch
    Sencha Inc, Senior Forum Manager
    ________________
    http://www.JSONPLint.com - Source to lint your JSONP!

    Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
    https://github.com/mitchellsimoens

    Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/

    Need more help with your app? Hire Sencha Services services@sencha.com

    Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is almost in print!

    When posting code, please use BBCode's CODE tags.

  4. #3
    Sencha User
    Join Date
    Feb 2012
    Posts
    16
    Vote Rating
    0
    vtu is on a distinguished road

      0  

    Default


    Thanks figured it out. I was assuming that it would created the model for me if I set the fields in the metadata.
    "fields: Config used to reconfigure the Model's fields before converting the response data into records"

Tags for this Thread