Skip to content

Instantly share code, notes, and snippets.

@feedhenry-gists
Created June 14, 2011 11:22
Show Gist options
  • Save feedhenry-gists/1024711 to your computer and use it in GitHub Desktop.
Save feedhenry-gists/1024711 to your computer and use it in GitHub Desktop.
Tutorial Sencha Touch List Creation
// Get contacts from device
$fh.contacts({act: 'list'}, function (data) {
// get the contacts array from data returned
var contacts = data.list;
// create the data store, passing in the contacts list
var store = new Ext.data.JsonStore({
model: app.m.contact, // the contact model that is registered in /client/default/script/models/contact.js
sorters: 'last', // sort by 'last' field
getGroupString: self.getGroupString, // the grouping callback for each item
data: contacts // contacts array
});
// create the Sencha list by passing in the data store containing the contacts
inst.v.cList = new Ext.List({
itemTpl: '{first} {last}', // template for displaying each contact e.g. 'George Washington'
grouped: true,
indexBar: true,
store: store
});
// Setup the container for our List
inst.v.cCard = new Ext.Container({
layout: 'card',
items: [inst.v.cList]
});
// Swap in our List container so it's visible
inst.v.mainPanel.prevCard.push(inst.v.mainPanel.getActiveItem());
inst.v.mainPanel.setActiveItem(inst.v.cCard, {
type: 'slide'
});
inst.v.cList.show();
}, function (e) {
// problem listing contacts, show error
....
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment