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.
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.
Public classes and class members are available for use by any other class or application code and may be relied upon as a stable and persistent within major product versions. Public classes and members may safely be extended via a subclass.
Protected class members are stable public
members intended to be used by the
owning class or its subclasses. Protected members may safely be extended via a subclass.
Private classes and class members are used internally by the framework and are not intended to be used by application developers. Private classes and members may change or be omitted from the framework at any time without notice and should not be relied upon in application logic.
static
label next to the
method name. *See Static below.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).
Let's look at each part of the member row:
lookupComponent
in this example)( item )
in this example)Ext.Component
in this case). This may be omitted for methods that do not
return anything other than undefined
or may display as multiple possible values
separated by a forward slash /
signifying that what is returned may depend on the
results of the method call (i.e. a method may return a Component if a get method calls is
successful or false
if unsuccessful which would be displayed as
Ext.Component/Boolean
).PROTECTED
in
this example - see the Flags section below)Ext.container.Container
in this example). The source
class will be displayed as a blue link if the member originates from the current class
and gray if it is inherited from an ancestor or mixed-in class.view source
in the example)item : Object
in the example).undefined
a "Returns" section
will note the type of class or object returned and a description (Ext.Component
in the
example)Available since 3.4.0
- not pictured in
the example) just after the member descriptionDefaults to: false
)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.
classInstance.method1().method2().etc();
false
is returned from
an event handler- 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
- 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
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.
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.
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.
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.
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:
Ext.button.Button
class has an alternate class name of Ext.Button
). Alternate class
names are commonly maintained for backward compatibility.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.
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:
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.
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.
The following guides are recommended reading before proceeding further:
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.
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.
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.
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
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:
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.
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
For common problems using Sencha Cmd, see the Troubleshooting section of Introduction to Sencha Cmd.
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.