PDA

View Full Version : How can we create the same structure that Sencha cmd creates with view and models



mohammedsardar
23 Apr 2017, 8:32 PM
Dear All,

When we use Sencha Cmd for a classic app creation and it creates many directories and sub directories to store the View, Model,Controller files.Actually that is taken care by Sencha cmd when we generate an app and it's a ALM tool. When we use only the fiddle where we don't have access to install Sencha trial versions at office, do we need to create the required folders manually to run an App ? Do we have any work around for that. Actually we are doing practice but it's time consume even simple School apps. Any comments will be much appreciated.

Thanks

florinmarinescu
24 Apr 2017, 7:10 AM
Hello,

As far as I know, there is no solution to generate the fiddle files automatically. What you can do is to fork from an existing working application (one that resembles as much as possible with you desired app) and further develop from that.

alexander.urban
24 Apr 2017, 9:50 AM
In fact, none of the folders or files is strictly required.

You can fill the existing app.js file with inline definitions. If you add a store there (either before Ext.application or inside the launch function) you don't need other files, let alone a folder structure. E.g.


Ext.define('MyApp.store.Test',{
...
});
Ext.application({
name : 'Fiddle',


launch : function() {
var store = Ext.create('MyApp.store.Test');
}
})

or


Ext.application({
name : 'Fiddle',


launch : function() {
Ext.define('MyApp.store.Test',{
...
});
var store = Ext.create('MyApp.store.Test');
}
})

Or you can use flat naming. MyApp.store.Test is in app/store/Test.js, but MyApp.TestStore is in app/TestStore.js

Of cource, once your project grows, you want to compartmentalize your files into stores, views and controllers, but for really small test projects, I usually define everything in a single file, or maybe two.

mohammedsardar
25 Apr 2017, 12:25 AM
Thank you and OKK.

Then we do compartmentalize only for categorize the files as views, models and controllers right ?

Also, As we can define a class inside the same Ext.application itself ?

Which means creating a class using Ext.define , creating the object of the same class , can we also use the same class fields and methods of the class inside master class ? I will practice this too.

Fiddle is fine but would be very helpful if it's like eclipse to open different files. Can we download the fiddle and make it as project ?

Thanks
Mohammed sardar

mitchellsimoens
25 Apr 2017, 4:05 AM
Fiddle isn't mean to be a development environment, it can serve as one but it's not designed to replace an editor/IDE for your project.

As @alexander.urban says, Ext JS and Cmd do not require files be placed in any specific place, we only recommend it to give a common structure. Ext.Loader holds a mapping of namespace to filesystem location and can then build a path to a file you are requiring. To help with that mapping, Cmd iterates over a selected number of places to find these classes and where they live on filesystem.

Since Fiddle is a web app, there is no Cmd so it can only work with the default Ext JS paths (Ext.app.Application will setup the path to app by default). This is why if you have Fiddle.view.Main at app/view/Main.js in fiddle (assuming you kept the name Fiddle in app.js), Ext JS knows exactly where to load it. If you tried loading Fiddle.foo.Bar it will attempt to load app/foo/Bar.js as it build that path.