How to break up a custom app into multiple js files

146 views Asked by At

I am using rally app builder, and App-debug.html to run the app externally. I defined a data store in a separate js file. How can I make App.js access the store? I am getting an error that store is not defined.

1

There are 1 answers

0
nickm On BEST ANSWER

Here is an example. Each file has a class defined with Ext.define().

App.js:

Ext.define('CustomApp', {
    extend: 'Rally.app.App',
    componentCls: 'app',
    items:{ html:'<a href="https://help.rallydev.com/apps/2.0rc2/doc/">App SDK 2.0rc2 Docs</a>'},
    launch: function() {
    var s = Ext.create('MyStore');
    var myStore = s._createStore();
    console.log(myStore);
    }
});

MyStore.js:

Ext.define('MyStore', {
    _createStore: function(){
        return Ext.create('Rally.data.WsapiDataStore', {
                model: 'User Story',
                fetch: ['FormattedID','Name'],
                pageSize: 100,
                autoLoad: true,
                context:{
                    project: '/project/1791267822',
                }
        });
    }
});

config.json:

{
   "name": "MyApp",
   "className": "CustomApp",
   "server": "https://rally1.rallydev.com",
   "sdk": "2.0rc2",
   "javascript": [
      "App.js",
      "MyStore.js"
   ],
   "css": [
      "app.css"
   ]
}