define data entry forms using the Ext.form.Panel class • Sencha Touch supports most HTML 5 input field types including the following • Check Box • Search • Date Picker • Select • Email Field • Slider • Fieldset • Spinner • Hidden • Text • Number • Text Area • Password • Toggle • Radio Buttons • URL Wednesday, June 5, 13
either deploy a Toggle control through the Ext.field.Toggle constructor or implicitly through the togglefield xtype { xtype: 'togglefield', name: 'active', label: 'Active?' } Wednesday, June 5, 13
events that occur within the app • "Glues" the view classes to the Model classes • Each component has many events • Named after the object (model) that it primarily deals with. • refs section contains pointers to components • control section attaches event listeners • refs and control use Ext.ComponentQuery syntax Wednesday, June 5, 13
of components // retrieve all Ext.Container that are direct children of the // container with an id of viewport var aCntrs = Ext.ComponentQuery.query("viewport > container") // retrieve all tabpanels and toolbars var aToolbarLists = Ext.ComponentQuery.query('tabpanel, toolbar'); // retreive all select fields with a name of "myfield" var cmpSelect = Ext.ComponentQuery.query('selectfield[name="myfield"]'); // first button with itemId of 'btn1' var btn = Ext.ComponentQuery.query('button#btn1')[0]; Wednesday, June 5, 13
items hierarchy looking for the first ancestor/descendant that matches a selector • query() is similar to down() but returns an array of matching items var owningTabPanel = formfield.up('tabpanel'); var cntr = button.up('container'); var form = cntrl.down('form'); var aContainers = Ext.ComponentQuery.query('container'); var sbtn = aContainers[0].down('button'); // returns all buttons in the container and the // container's descendants var allButtons = myContainer.query("button"); Wednesday, June 5, 13
communications between a form and the server are handled through a data model • With a single command you can populate form fields from a model • You will validate the data in a model, prior to transferring the data to the server via AJAX Wednesday, June 5, 13
back into your model instance • Transfer data from a model to a form var model = Ext.create(‘MyApp.model.Settings’); myForm.updateRecord(model); var errors = model.validate(); Wednesday, June 5, 13
• The Ext.MessageBox class contains a number of methods that enable you to output modal popup boxes • Executes asynchronously • You can invoke each of the following methods from the Ext.Msg singleton class – alert(String title, String msg, [Function fn], [Object scope]) – confirm (String title, String msg, [Function fn], [Object scope]) – prompt (String title, String msg, [Function fn], [Object scope], [Boolean/number multiline],[String value], Object promptConfig) Wednesday, June 5, 13
enables you to store keyname/value pairs on the device • Stored data persists on your device, even after a power-down • Represented in Sencha Touch as the LocalStorageProxy class • Store up to 5MB on most devices • SessionStorage is also available • Sencha Touch 2.1+ includes a Web SQL proxy Wednesday, June 5, 13
the HTML5 localStorage API to save Model data locally on the client browser • Extremely useful for saving user-specific info without needing to build server-side infrastructure to support it • HTML5 localStorage is a key-value store (e.g. cannot save complex objects) • LocalStorageProxy automatically serializes and deserializes abstract data types as JSON when saving and retrieving them • Attach the localstorage proxy to a Ext.data.Model or Ext.data.Store proxy: { type: 'localstorage', id: 'someID' } Wednesday, June 5, 13
to inform the user of a slight delay while the transaction takes place • In your success and failure handlers you hide the loadmask to turn off the wait message • Use Ext.decode() to parse complex data that is represented as JSON Wednesday, June 5, 13
& solutions from: • https://github.com/savelee/conferences/ • Objectives – Build & handle Forms – Create Controllers – Create Static methods – Create a JSONP API request – Save data in the localstorage Wednesday, June 5, 13