PDA

View Full Version : Ext.List - JSON



madsovenielsen
11 Apr 2012, 7:17 AM
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


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:



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.

scottmartin
11 Apr 2012, 10:06 AM
I have not tried this. Have you tried? .. and are you receiving any errors?

Regards.
Scott.

madsovenielsen
11 Apr 2012, 11:15 AM
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