
Originally Posted by
Carlos Nunes
Hi all, I'm currently implementing a portal using .net mvc and extjs(no mvc), but I would like to start organizing my extjs code with mvc too. So far I have followed your tutorial and I could implement a store getting data from a .net controller and show the grid in the view.
But my doubt is that in my application I have a lot of .net mvc views and I'm not sure how to organize extjs code for all of them. Should I have an app.js for each view? or there is a better way to do it and maybe reusing code.
Thanks in advance,
Carlos Nunes
No I don't think app.js should be duplicated.
I think you should create, eventually, multiple Viewport.js (and so you have to avoid autoload it).
Possibly, you should generate a part of javascript code in this way:
// scss coffee
Code:
Ext.application({
name: 'MyApp',
launch: <generate this function with .net>
});
So you can run the correct Viewport.
A different approach could be: have only one viewport which will build differently, based upon some values that you generate through .net.
This could be the best option (the second one) because you'll stick with ExtJS app structure.
However, all these solutions involve generating javascript code dinamically, which is something that I don't like and feels really incorrect.
Maybe you can create Viewport.js so that will be dinamically generated by including another file, choosing it from your views which are written in plain javascript. This could be a good idea, so you'll have something like this:
Viewport.js.cs
->Include <myview_based_on_link.js>
So you can keep .net mvc directory structure too, even for views
Notice that I don't use .net MVC, but I did something similar with Ruby on Rails. Don't know if it's a good idea, but looks interesting for me.