Created
June 14, 2011 11:22
-
-
Save feedhenry-gists/1024711 to your computer and use it in GitHub Desktop.
Tutorial Sencha Touch List Creation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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