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

      0  

    Default Answered: Mapping data set onto store

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

  3. #2
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    37,649
    Vote Rating
    898
    Answers
    3575
    mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute

      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
    ________________
    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 in print!

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

Thread Participants: 1

Tags for this Thread