PDA

View Full Version : Extjs MVC with .Net MVC



Carlos Nunes
19 Nov 2012, 10:35 AM
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

Fire-Dragon-DoL
19 Nov 2012, 4:34 PM
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


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.

Carlos Nunes
20 Nov 2012, 6:02 AM
@Fire-Dragon-DoL thanks for the answer.

In my project I'm using Container instead of Viewport because I want the Extjs components inside a div in HTML template page. And if I use one application with a container for each View (.net View) is there any problem (performance or other kind of it)?

Thanks,
Carlos Nunes