Docs Help

Terms, Icons, and Labels

Many classes have shortcut names used when creating (instantiating) a class with a configuration object. The shortcut name is referred to as an alias (or xtype if the class extends Ext.Component). The alias/xtype is listed next to the class name of applicable classes for quick reference.

Access Levels

Framework classes or their members may be specified as private or protected. Else, the class / member is public. Public, protected, and private are access descriptors used to convey how and when the class or class member should be used.

Member Types

Member Syntax

Below is an example class member that we can disect to show the syntax of a class member (the lookupComponent method as viewed from the Ext.button.Button class in this case).

lookupComponent ( item ) : Ext.Component
protected

Called when a raw config object is added to this container either during initialization of the items config, or when new items are added), or {@link #insert inserted.

This method converts the passed object into an instanced child component.

This may be overridden in subclasses when special processing needs to be applied to child creation.

Parameters

item :  Object

The config object being added.

Returns
Ext.Component

The component to be added.

Let's look at each part of the member row:

Member Flags

The API documentation uses a number of flags to further commnicate the class member's function and intent. The label may be represented by a text label, an abbreviation, or an icon.

Class Icons

- Indicates a framework class

- A singleton framework class. *See the singleton flag for more information

- A component-type framework class (any class within the Ext JS framework that extends Ext.Component)

- Indicates that the class, member, or guide is new in the currently viewed version

Member Icons

- Indicates a class member of type config

- Indicates a class member of type property

- Indicates a class member of type method

- Indicates a class member of type event

- Indicates a class member of type theme variable

- Indicates a class member of type theme mixin

- Indicates that the class, member, or guide is new in the currently viewed version

Class Member Quick-Nav Menu

Just below the class name on an API doc page is a row of buttons corresponding to the types of members owned by the current class. Each button shows a count of members by type (this count is updated as filters are applied). Clicking the button will navigate you to that member section. Hovering over the member-type button will reveal a popup menu of all members of that type for quick navigation.

Getter and Setter Methods

Getting and setter methods that correlate to a class config option will show up in the methods section as well as in the configs section of both the API doc and the member-type menus just beneath the config they work with. The getter and setter method documentation will be found in the config row for easy reference.

History Bar

Your page history is kept in localstorage and displayed (using the available real estate) just below the top title bar. By default, the only search results shown are the pages matching the product / version you're currently viewing. You can expand what is displayed by clicking on the button on the right-hand side of the history bar and choosing the "All" radio option. This will show all recent pages in the history bar for all products / versions.

Within the history config menu you will also see a listing of your recent page visits. The results are filtered by the "Current Product / Version" and "All" radio options. Clicking on the button will clear the history bar as well as the history kept in local storage.

If "All" is selected in the history config menu the checkbox option for "Show product details in the history bar" will be enabled. When checked, the product/version for each historic page will show alongside the page name in the history bar. Hovering the cursor over the page names in the history bar will also show the product/version as a tooltip.

Search and Filters

Both API docs and guides can be searched for using the search field at the top of the page.

On API doc pages there is also a filter input field that filters the member rows using the filter string. In addition to filtering by string you can filter the class members by access level, inheritance, and read only. This is done using the checkboxes at the top of the page.

The checkbox at the bottom of the API class navigation tree filters the class list to include or exclude private classes.

Clicking on an empty search field will show your last 10 searches for quick navigation.

API Doc Class Metadata

Each API doc page (with the exception of Javascript primitives pages) has a menu view of metadata relating to that class. This metadata view will have one or more of the following:

Expanding and Collapsing Examples and Class Members

Runnable examples (Fiddles) are expanded on a page by default. You can collapse and expand example code blocks individually using the arrow on the top-left of the code block. You can also toggle the collapse state of all examples using the toggle button on the top-right of the page. The toggle-all state will be remembered between page loads.

Class members are collapsed on a page by default. You can expand and collapse members using the arrow icon on the left of the member row or globally using the expand / collapse all toggle button top-right.

Desktop -vs- Mobile View

Viewing the docs on narrower screens or browsers will result in a view optimized for a smaller form factor. The primary differences between the desktop and "mobile" view are:

Viewing the Class Source

The class source can be viewed by clicking on the class name at the top of an API doc page. The source for class members can be viewed by clicking on the "view source" link on the right-hand side of the member row.

Cmd 7.7.0


top

Using Sencha Cmd with Sencha Touch

Introduction

This guide walks you through the process of using Sencha Cmd with Sencha Touch applications starting with the sencha generate app command and ending with a running application.

This guide applies to both new Sencha Touch applications as well as upgrades of existing Sencha Touch 2 applications.

Prerequisites

The following guides are recommended reading before proceeding further:

Creating a New Application

The following command generates a new application with the namespace MyApp to "/path/to/www/myapp":

#  Make sure the current working directory is the Sencha Touch SDK
cd /path/to/sencha-touch-sdk
sencha generate app MyApp /path/to/www/myapp

Or, you can specify the path to the SDK on the command line:

sencha -sdk /path/to/sencha-touch-sdk generate app MyApp /path/to/www/myapp

To try it out, simply point any WebKit-based browser to http://localhost/myapp.

Congratulations. You have just created a fully working Sencha Touch application in seconds.

Understanding Your Application's Structure

The generated application should have the following file structure:

.sencha/                # Sencha-specific files (for example configuration)
    app/                # Application-specific content
        sencha.cfg      # Configuration file for Sencha Cmd
        plugin.xml      # Plugin for Sencha Cmd
    workspace/          # Workspace-specific content (see below)
        sencha.cfg      # Configuration file for Sencha Cmd
        plugin.xml      # Plugin for Sencha Cmd

touch/                  # A copy of the Sencha Touch SDK
    cmd/                # Sencha Touch-specific content for Sencha Cmd
        sencha.cfg      # Configuration file for Sencha Cmd
        plugin.xml      # Plugin for Sencha Cmd
    src/                # The Sench Touch source
    sencha-touch-*.js   # Pre-compiled and bootstrap files
    ...

app                     # Your application's source code in MVC structure
    controller
    model
    profile
    store
    view
        Main.js         # The main view of the application

resources
    css
        app.css         # The main stylesheet, compiled from app.scss

    sass
        app.scss        # The Sass file which compiles to app.css above,
                        # includes Sencha Touch theme by default

    icons               # Application icons for all mobile devices
                        # When replacing these default images with your own,
                        # make sure the file name and the dimension stays exactly the same
        ...
    loading             # Application start-up screens for iOS devices
                        # Similarly to icons, make sure the file names and
                        # dimension stays the same
        ...
    images              # Put other images used by your application here

index.html
app.js                  # Contains application's initialization logic
app.json                # Application descriptor
packager.json           # Configuration for native packaging

Both "app.json" and "packager.json" have inline documentation for each configurable item. Simply open the files and edit them as you need.

Developing Your Application

Using the family of sencha generate commands helps you quickly generate common MVC components.

Important. Be sure to make your current directory your application's root folder.

For example:

cd /path/to/www/myapp
sencha generate model User id:int,name,email

This command generates a new Model class named User with three fields named id, name, and email to "app/model/User.js" and add its reference to your "app.js" file.

Upgrading Your Application

Generated applications always have their own copies of the SDK from which they were originally generated. Upgrading your application to a new version of the SDK means that you have to replace the old version with the new one. Do this with the command sencha app upgrade.

Important Be sure to make your current directory your application's root folder.

Here's a more complete example:

cd /path/to/www/myapp
sencha app upgrade /path/to/new_version_of_sdk

Deploying Your Application

Developing your application simply means editing source code and refreshing the browser. All source files are dynamically loaded on demand. There's no building process involved. When it comes to deployment, Sencha Cmd provides the following four build environment options:

  • testing - intended for QA prior to production. All JavaScript and CSS source files are bundled, but not minified, which makes it easier to debug.
  • package - creates a self-contained, redistributable production build that normally runs from the local file system without a web server.
  • production - creates a production build that is normally hosted on a web server and serves multiple clients (devices). The build is offline-capable using HTML 5 application cache, and is enabled to perform over-the-air updates.
  • native - first generates a package build, then packages it as a native application, ready to be deployed to native platforms.

As an example, the following command generates a testing build of your application.

Important. Be sure to make your current directory your application's root folder.

cd /path/to/www/myapp
sencha app build testing

And similarly when you're ready for production deployment:

cd /path/to/www/myapp
sencha app build production

The default deployment paths are taken from the buildPaths item inside app.json. For more details on optional arguments, run the following command:

cd /path/to/www/myapp
sencha help app build

Sencha Cmd automates all optimizations for your application, including the following:

  • Resolving dependencies required by the application and only including exactly what is used for optimal file size/performance.
  • Enabling HTML5 application cache via automatic generation of "cache.manifest" and resources checksum.
  • Minifying all JavaScript and CSS assets.
  • Storing all JavaScript and CSS assets inside local storage on first load and patching them via delta updates between releases.

As a result, your production build can load instantly on subsequent access and updates on the fly with minimal network transfer.

Important. The cache.manifest file is automatically generated for you. Make sure your web server serves it with the correct Content-Type header of text/cache-manifest. To learn more about HTML5 application cache, see the HTML5 Rocks tutorial A Beginner's Guide to Using the Application Cache.

Packaging Your Application for Distribution in App Stores

packager.json contains all configurable values to package your application.

If you're using OS X and have XCode installed, the following command packages your application and runs it on the iOS Simulator:

sencha app build native

Troubleshooting

For common problems using Sencha Cmd, see the Troubleshooting section of Introduction to Sencha Cmd.

Errors While Resolving Dependencies - Part 2

The new Sencha Cmd compiler is used by default to determine dependencies. Unlike previous releases, the compiler determines dependencies by processing source code (application and framework). In some cases this can lead to missing dependencies, that is, dependencies that were automatically detected in previous releases but are not detected by the compiler.

The ideal solution in this case is to add the missing requires statements to resolve the issue. This may include switching overrides to the new, named form, such as:

Ext.define('MyApp.patches.foo.Bar', {
    override: 'Ext.foo.Bar',
    ...
});

This enables overrides to be required by their name and therefore for the compiler to process them in the right sequence.

If that effort needs to be postponed, you can enable V2 compatibility mode (based on launching your application via file system protocol inside of a headless WebView to extract dependencies). To do this, use this command instead of sencha app build:

sencha config -prop v2deps=true then app build

Alternatively, you could add the following line to your ".sencha/app/sencha.cfg" file and run sencha app build as before:

v2deps=true

In this legacy mode, if your application relies on any dynamic server-side scripting (for example, loading a class configuration from a PHP script), you must set the url item inside app.json to the absolute URL from which your application can be loaded on a web browser. For example:

// app.json
{
    "url": "http://localhost/myapp/",
    // ...
}

This should be viewed as a temporary measure, since it won't allow planned compiler optimizations to automatically benefit your application.

Next Steps

Cmd 7.7.0