View Full Version : MVC on Sencha Touch : First Thoughts and Few Questions.

12 Feb 2011, 1:24 PM
Hi Everyone,

I am trying to build some interesting apps for the Ipad & Android. Honestly, Sencha has been a real lot of fun to play around with, kudos to the devs for building something which looks really well thought out.

FYI , I am completely new to Sencha & ExtJS but have a lot of experience with js & Jquery

So have been looking though the Sencha Touch Codebase along with the Ext JS to try and understand the basic philosophy behind the "Sencha" way doing things expecially the MVC part as that currently is a bit confusing for me.

Here's what I get:

This is an pretty much a clean implementation of a standard "ORM" style* MVC pattern with

Model being represented by : -
1) Ext.Model :-> Object representation of Entities
2) Ext.Store :-> Collection of Specific/Subset of Model Objects
3) Ext.Proxy :-> Glue for data retrieval / update of Server Backend.

Controller being represented by : -
1) Ext.Controller : - for 'controller' stuff :)
2) Ext.Dispatch : - for actual message passing between the controllers & views
3) Ext.Router :- for using the inbuilt history support to move between screens

View being represented by : -
1) Ext.Component and Ext.Container subclasses.

**(not exactly true but if u consider the server side to be a "transparent" crud proxy to the DB it kinda can be called that)

Given the above , here are some things which are not really very clear to me.

1) Is Binding the Lists & Data Views to the Stores a two way bind?

What i mean to say is basically, for example , if I have a Store filled with User Objects directly bound to the List, and let the user select multiple Users, Is there a way of making the Store "filter " itself so that any other derived list automatically filters itself based on the selection?

2) Does the framework support lazy loading of object or do we need to manage that explicitly.

Please feel free to correct me if any of my assumptions are wrong or if I am totally going up a blind alley,


Just Shrey

14 Feb 2011, 5:49 AM
Answer to your first question is yes and no. By default it is only one way, your List/DataView is aware of your Store but your Store is not aware of your List/DataView. You can, however, when creating the components add a reference back to your List/DataView, basically setting a public property when the Store is created.

As for the second question, you can use XTypes to do lazy loading. For mobile devices, I HIGHLY recommend this as the component will get made when needed (lazy loading of course).


xtype: "panel",

But if you do this:

var newPanel = new Ext.Panel({ .... });

That component's object is created whenever the browser comes accross it therefor is basically loaded and taking up memory/CPU even when not needed.

Each class has an XType, you can find the common ones in the API Docs if you look under Ext -> Component. You can also look in the src folder for each class and at the end you will see the Ext.reg function that binds a string (which is the XType) to the actually class.