1. #1
    Sencha User
    Join Date
    Nov 2012
    Posts
    6
    Vote Rating
    -1
    tharahan is an unknown quantity at this point

      0  

    Default Unanswered: Create a Store from a subset of JSON Store

    Unanswered: Create a Store from a subset of JSON Store


    Hi

    I have a json store defined as follows

    var subAccountStore = new Ext.data.JsonStore({
    autoLoad: true,
    proxy: {
    type:'ajax',
    url : '/opUI/json/subaccount.action?name="ABC"'
    },
    fields: ['accountName', 'quantity','accountNumbers'],
    listeners: {
    load: function(store, records, success) {
    // ???????
    },
    single: true
    }

    });

    and sample data is

    [{"accountName":"'ABC'","quantity":100,"accountNumbers":['12345A','12345B','12345C']},{"accountName":"'XYZ'","quantity":100,"accountNumbers":['99999A','99999B','99999C']}]

    How do I create a store dynamically for "accountNumbers" and assign to combo box inside the grid?

    Thanks
    Tharahan

  2. #2
    Sencha Premium Member
    Join Date
    Feb 2012
    Location
    North Carolina
    Posts
    298
    Answers
    3
    Vote Rating
    14
    worthlutz will become famous soon enough

      0  

    Default


    Try defining your data using several models and use the "hasMany" association for the accountNumbers.

    Code:
    Ext.define('MyApp.model.AccountNumbers',
        fields: [
            { name: 'accountNumber'
            }
        ],
        belongsTo: 'MyApp.model.Accounts',
    );
    
    Ext.define('MyApp.model.Accounts',
        fields: [
            { name: 'accountNumber' },
            { name: 'quantity'}
        ],
        hasMany: {
            name: 'accountNumbers',
            model: 'myApp.model.AccountNumber'
        }
    );
    I'm not sure I've got the code correct but you should get the idea.
    Check the docs: http://docs.sencha.com/ext-js/4-1/#!/api/Ext.data.Model

    Worth

Thread Participants: 1