Skip to content

Instantly share code, notes, and snippets.

@mcmatrix
Forked from sagarpanda/sencha touch model
Created February 15, 2017 08:24
Show Gist options
  • Select an option

  • Save mcmatrix/bb5eeb0ad8ae67cdf24a5ac71b4dc7f0 to your computer and use it in GitHub Desktop.

Select an option

Save mcmatrix/bb5eeb0ad8ae67cdf24a5ac71b4dc7f0 to your computer and use it in GitHub Desktop.
sencha touch tips
# add extra coloum for fullname in sencha touch model
Ext.define('Sencha.model.Employee', {
extend: 'Ext.data.Model',
config: {
fields: [
{name: 'firstName', type: 'string'},
{name: 'lastName', type: 'string'},
{
name: 'fullName',
type: 'string',
convert: function (value, record) {
firstName = record.data.firstName;
lastName = record.data.lastName;
fullName = firstName + " " + lastName;
return fullName;
}
}
]
},
load: function () {
console.log("Employee model");
this.callParent(arguments);
}
});
abortRequest: function() {
var req = this.getActiveRequest();
if (req) {
delete req.options.success;
delete req.options.failure;
delete req.options.callback;
Ext.Ajax.abort(req);
}
}
ref:
http://www.sencha.com/forum/showthread.php?232899
# sencha touch cdn link
http://cdn.sencha.com/touch/sencha-touch-2.3.1/resources/css/sencha-touch.css
http://cdn.sencha.com/touch/sencha-touch-2.3.1/sencha-touch-all.js
# create an instance of a class
var instance = Ext.create('Ext.Panel');
var myInstance = Ext.create('MyApp.view.MyNote');
# get controller instance
add controller in app.js like controllers: ['myXyzController'], then
var controllerInstance = Trustomer.app.getController('myXyzController');
# get Store instance
add `storeId` property while creating store class, ex: storeId: 'cmp_storeid_myXyzStore'
var storeInstance = Ext.getStore('cmp_storeid_myXyzStore');
# clear store
// get all records
var range = Ext.getStore('cmp_storeid_myXyzStore').getRange();
// clear all records
Ext.getStore('cmp_storeid_newsstore').remove(range);
# Sencha Touch textareafield height solutions
http://alvinalexander.com/javascript/sencha-touch-textareafield-height-fullscreen-solutions
# Tap event in Panel and Container, example:
listeners: [{
element: 'element', delegate : '.thumbnail', event: 'tap',
fn: function(e){ console.log(e.getTarget().getAttribute('data-name')); }
}]
ref: http://www.sencha.com/forum/showthread.php?271855-add-listener-for-multiple-element-sencha-touch
# Sencha list paging plugin
ref: http://stackoverflow.com/questions/7321446/sencha-list-paging-plugin
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment