View Full Version : The Model Package for ExtJS and Sencha Touch

17 Mar 2012, 5:55 PM
How much the same/different are the data models from Sencha Touch2 and ExtJS 4?

As far as I saw there is only the config property different?

Is there maybe a trick to see if the Ext object is Sencha Touch or ExtJS?

I would like to do something like:

var config = Ext.madeUpFunction.isTouch() ? {config:config} : config;
Ext.define('MyApp.data.SomeModel', config);


19 Mar 2012, 5:40 AM
For the Model class that is pretty much it for when you create your model class.

19 Mar 2012, 9:46 AM
Great :)

Will !!Ext.versions.touch be reliabe in the future to distinguish between Ext and Touch?


19 Mar 2012, 9:56 AM
Between Ext JS 4 and Sencha Touch 2 is will be.

19 Mar 2012, 10:06 AM
great, thx!

For other people interested in a solution:

* Returns ExtJS4 or Sencha Touch 2 model config
var plattformizeModelConfig = function(extJsModelConfig) {
if(Ext.versions.extjs) {
return extJsModelConfig; // nothing to change, we are on ext
} else if(Ext.versions.touch) {
// transform to Sencha Touch 2 data model
var config = {
extend: extJsModelConfig.extend,
config: extJsModelConfig
delete config.config.extend;
return config;
} else {
Ext.Error.raise('Could not recognize Library');


19 Mar 2012, 10:10 AM
For a test I am wondering if you can use the config object and call this.initConfig(config); in the constructor if that will work.

19 Mar 2012, 10:12 AM
Maybe I'm wrong, but this doesn't sound very bulletproof, since I can image that this behavior can easily change.