Sencha Touch - Creating custom views

 Sencha allow developers to easily develop MVC based mobile application. Now I am going to explain the steps for creating custom views in sencha application. Before going to start, see my previous post for understanding the folder structure of sencha touch application (here).
 Inside the view folder I am going to create a MyView.js file with following code.
      extend : 'Ext.Panel',
      xtype : 'myview',
      config : {
            fullscreen : true,
            html : 'This is my own view'

 Here I have extended a Panel class and included a simple html content, whenever it's render, it's says "This is my own view". The "SenchaDemo.view.MyView" have special meanings.

    1. The "SenchaDemo" refer my application name.
    2. The "view" refer the view folder present in app folder.
    3. "MyView" is my view name.
    4. "myview" is my custom xtype value.

 Now I am going to include my custom view into my app.js file. The app.js file is starting point of my application and I have included the following code into app.js. The Ext.application used for loading all the necessary components and indirectly it call the launch function when all the files are loaded successfully. It's equivalent to onload function in web application.

 Here views : ['MyView'] includes the MyView into application. You can include the more then one view using comma separator. For example views : ['MyView','MyView1']. Now I am going add my view into Viewport.
      name : 'SenchaDemo',
      views : ['MyView'],
      launch : function() {
Now I am going to preview my application using safari browser. 

Here you can able to download this application.