1. #1
    Sencha User
    Join Date
    May 2010
    Posts
    15
    Vote Rating
    0
    madsovenielsen is on a distinguished road

      0  

    Default Unanswered: Ext.List - JSON

    Unanswered: Ext.List - JSON


    Hello

    Is it possible to use JSON as the data format in a Ext.List ?

    Example from http://docs.sencha.com/touch/1-1/#!/api/Ext.List
    Code:
    Ext.regModel('Contact', {
        fields: ['firstName', 'lastName']
    });
    
    var store = new Ext.data.JsonStore({    model  : 'Contact',
        sorters: 'lastName',
    
        getGroupString : function(record) {
            return record.get('lastName')[0];
        },
    
        data: [
            {firstName: 'Tommy',   lastName: 'Maintz'},
            {firstName: 'Rob',     lastName: 'Dougan'},
            {firstName: 'Ed',      lastName: 'Spencer'},
            {firstName: 'Jamie',   lastName: 'Avins'},
            {firstName: 'Aaron',   lastName: 'Conran'},
            {firstName: 'Dave',    lastName: 'Kaneda'},
            {firstName: 'Michael', lastName: 'Mullany'},
            {firstName: 'Abraham', lastName: 'Elias'},
            {firstName: 'Jay',     lastName: 'Robinson'}
        ]
    });
    
    var list = new Ext.List({
        fullscreen: true,
        
        itemTpl : '{firstName} {lastName}',
        grouped : true,
        indexBar: true,
        
        store: store
    });
    list.show();
    So something like this instead:

    Code:
    Ext.regModel("Contact", {
        fields: ["firstName", "lastName"]
    });
    var store = new Ext.data.JsonStore({
        model  : "Contact",
        sorters: "lastName",
        getGroupString : function(record) {
            return record.get("lastName")[0];
        },
        data: [
            {"firstName": "Tommy",   "lastName": "Maintz"},
            {"firstName": "Rob",     "lastName": "Dougan"},
            {"firstName": "Ed",      "lastName": "Spencer"},
            {"firstName": "Jamie",   "lastName": "Avins"},
            {"firstName": "Aaron",   "lastName": "Conran"},
            {"firstName": "Dave",    "lastName": "Kaneda"},
            {"firstName": "Michael", "lastName": "Mullany"},
            {"firstName": "Abraham", "lastName": "Elias"},
            {"firstName": "Jay",     "lastName": "Robinson"}
        ]
    });
    var list = new Ext.List({
        fullscreen: true,
        
        itemTpl : "{firstName} {lastName}",
        grouped : true,
        indexBar: true,
        
        store: store
    });
    list.show();
    Any suggestions are very welcome.

  2. #2
    Sencha - Support Team scottmartin's Avatar
    Join Date
    Jul 2010
    Location
    Houston, Tx
    Posts
    9,075
    Answers
    673
    Vote Rating
    467
    scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future

      0  

    Default


    I have not tried this. Have you tried? .. and are you receiving any errors?

    Regards.
    Scott.

  3. #3
    Sencha User
    Join Date
    May 2010
    Posts
    15
    Vote Rating
    0
    madsovenielsen is on a distinguished road

      0  

    Default


    Quote Originally Posted by scottmartin View Post
    I have not tried this. Have you tried? .. and are you receiving any errors?

    Regards.
    Scott.
    Nope, i dont have a working Sencha environment up and running.

    Kind regards Mads Nielsen

Thread Participants: 1

Tags for this Thread