1. #1
    Sencha User
    Join Date
    Jan 2012
    Posts
    19
    Vote Rating
    0
    Answers
    1
    wxkevin is on a distinguished road

      0  

    Default Answered: Best Way to Model a List or Set of values

    Answered: Best Way to Model a List or Set of values


    What is the best way in Ext JS 4 to model a List or Set of String values returned from a REST call? I was trying to use a Model but that didn't work too well. I want to display a list of returned values in a Multiselect. Here is the returned JSON:

    {"theList":[{"value":"something1"},{"value":"something2"},{"value":"something3"}]}

    How would you create you model?

  2. Don't forget the "root" property in the reader.

    Code:
    Ext.define('MyModel', {
        extend: 'Ext.data.Model',
        fields: [
            {name: 'value',  type: 'string'}
        ],
        proxy: {
            type: 'rest',
            url : 'my.url',
            reader: {
                type: 'json',
                root : 'theList',
            }
        }
    
    });
    Good luck!

  3. #2
    Sencha Premium Member EPV's Avatar
    Join Date
    Dec 2010
    Location
    Sweden
    Posts
    197
    Vote Rating
    15
    Answers
    23
    EPV will become famous soon enough

      0  

    Default


    Don't forget the "root" property in the reader.

    Code:
    Ext.define('MyModel', {
        extend: 'Ext.data.Model',
        fields: [
            {name: 'value',  type: 'string'}
        ],
        proxy: {
            type: 'rest',
            url : 'my.url',
            reader: {
                type: 'json',
                root : 'theList',
            }
        }
    
    });
    Good luck!

  4. #3
    Sencha User
    Join Date
    Jan 2012
    Posts
    19
    Vote Rating
    0
    Answers
    1
    wxkevin is on a distinguished road

      0  

    Default


    Thanks. It worked.

Thread Participants: 1

Tags for this Thread