PDA

View Full Version : Using Data In Sencha Mobile vs Ext JS



igriffin
8 Aug 2010, 4:41 PM
I've done a significant amount of working in Ext JS and have been very excited about the possibilities with Sencha Mobile. After some proof of concept with porting portions of our UI to be used in a mobile environment with Sencha Mobile, I found that a considerable amount of what I've been doing with UI moves right over. Obviously, there are some areas where a mobile-specific version must be created. Now that we have discovered how we can utilize the UI, I turned my sights to wiring up the UI to our data sources. This has not been as painless.

It seems that in Sencha Mobile I cannot just load a JsonStore (or other data.Store) with my data by setting a 'fields' object, but I must instead use the concept of Ext.data.Model. The documentation for JsonReader states the by defining a set of fields, Sencha Mobile will create an Ext.data.Model under the hood. From what I'm seeing, this just isn't happening. The fields object I supplied (and that has worked under Ext JS) appears to be ignored and a new Ext.data.Model is created with every field in my data being mapped, including the fields above the 'root' I designated in my store. Additionally, I only load 2 fields into the store under Ext JS and have been converting one of those fields during the load whereas now it is loading everything I receive from the server.

Bottom line, while I expected to rewrite the UI for mobile, I did not expect to have to rewrite my data load methods and stores. It would seem that if I'm using Ext JS and Sencha Mobile, I could have a fair amount of code reuse. Is Ext.data.Model the way of the future for Ext JS? At least then I could plan to later use one code base rather than maintaining separate code for mobile and non-mobile. There's also some little differences such as a JsonStore firing 'load' after loading data whereas a JsonStore in Sencha Mobile fires 'datachanged'. Again, frustrating to rewrite code due to the one minor change (yes, I can obviously write my own event 'load' and listen to 'datachanged', then fire 'load' so I can reuse my old code, but it's a workaround where it would seem it should 'just work' between two complementary products from one company).

Or perhaps I'm doing something very wrong, I'd love to hear a data solution that works for both Ext JS and Sencha Mobile.

-Ian

evant
8 Aug 2010, 5:51 PM
We realise that people will want to use the same business logic and data for both desktop and mobile apps, so the Ext 4 data package will mirror the one that is used in Touch, in fact it's exactly the same code base so far.

Up until that point, you'll need to keep going along as you are, but we're working to consolidate the API so it will be seamless in future versions.

igriffin
9 Aug 2010, 4:04 AM
We realise that people will want to use the same business logic and data for both desktop and mobile apps, so the Ext 4 data package will mirror the one that is used in Touch, in fact it's exactly the same code base so far.

Up until that point, you'll need to keep going along as you are, but we're working to consolidate the API so it will be seamless in future versions.

Thanks for the prompt reply. This is what I need to hear at this point. I expect some changes moving to Ext 4, but as long as Ext/Sencha is moving toward a common codebase, I can deal with differences for now (and learn about what's coming next). It would be nice to see a public beta (or private for subscribers) of Ext JS 4 for now, but I'm guessing we'll see it right after the conference November.

Code reuse across the mobile and desktop platforms will be essential to our business and will be a driving factor behind our continued use of Ext/Sencha.

-Ian

roberthenniger
5 Feb 2011, 3:20 AM
Hi, thanks for the clarification. I was also wondering the last days.
It seems the old "Store" Model with loading column information is not supported anymore?

Currently we have an Extjs Application which uses the onMetaChange event to init the column model itself from a server response. Our column model is defined over the ORM on business logic site.
I dont see how this can be achieved in sencha touch/extjs 4.0.
Maybe we have to preload "all" column models to the ModelMgr first?!
Can anyone give me a hint on this?

Thanks in advance.

Robert