1. #1
    Sencha User
    Join Date
    Aug 2012
    Posts
    74
    Vote Rating
    0
    Answers
    5
    alex9311 is on a distinguished road

      0  

    Default Unanswered: Mapping data set onto store

    Unanswered: Mapping data set onto store


    Hey all,
    I'm taking a store, grouping it, doing getGroups() on it, and mapping that array onto a new store. Code:

    Code:
            
    createStore:function(){
                    var store = Ext.data.StoreManager.lookup('Store');
                    store.group('activities');
                    var groups = store.getGroups();
                    console.log(groups);
                    var groupStore = Ext.create('Ext.data.Store', {
                            model: 'APP.model.Activities',
                            fields: [{
                                    name:'activities', mapping: 'name'
                            }, {
                                    name: 'total', convert: function(value, record){
                                            console.log("hey");
                                            return record.raw.children.length;
                                    }
                            }],
                            data: groups
                    });
            console.log(groupStore);
            return groupStore;
            }
    This is a method in my chart definition and I'm calling it in the initComponent like so:
    Code:
            
    initComponent: function(){
                    this.store = this.createStore();
                    this.callParent(arguments);
            },
    The store that I get out of the function has the right number of entries and fields but the data is all zeroes. I cant see the console output "hey" that I put in the convert function. So somehow store is created but none of the mapping happens, yet the fields are correctly named "total" and "activities". Anyone have any ideas? I've been banging my head on this all day

  2. #2
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    St. Louis, MO
    Posts
    33,714
    Vote Rating
    438
    Answers
    3113
    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


    First issue I see is you are specifying the model and fields config in your group store, you should only have 1 of them.
    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.