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.
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.