0

I started developing a prototype in ExtJS4 following their new MVC pattern. I have a master form (customers) with a list of customers (grid) and a details form, double-clicking on a row in the grid opens the details form. Currently, I have done in the controller for the master form like this:

var view = Ext.widget('CustomerDetailsView');
view.show();

But I also need to pass in the customerID to the details form to have the details form load additional data for the customer. In the simple MVC sample app at the Sencha web site this is done by:

view.down('form').loadRecord(selectedRecord);

So the way I understand this is that the details view is loaded with the whole record from the master view. First, my details view has it's own controller and store, and second, that does not seem like the right way to communicate between views.

  • Shouldn't the Master controller somehow call the Details controller?
  • in another post here it was suggested using events for all this communication between views/controllers, but I am not sure it makes sense to create all these application-wide events just for a simple master/details communication

What is the suggested way to pass data to a child view/controller in the ExtJS4 MVC application pattern?

Community
  • 1
  • 1
Mike WP
  • 71
  • 1
  • 7
  • I've explained one way of doing this using routes in here.http://stackoverflow.com/a/24125359/434319 – BuddhiP Jun 09 '14 at 17:35

1 Answers1

1

There is not a single "right" way to do things here. It's really up to you to structure your application that makes the most sense. You don't have to have a single controller for a single view. In fact I would say that one controller should respond to events from multiple views as a general rule. Of course, if you have a super complicated views and your controller class is getting out of hand - by all means break it up.

Now to answer your questions that you asked:

  1. Yes you can have one controller talk to another: from Master controller - this.getController('DetailsController').doSomething();

  2. You are in the driver seat here. Ultimately you make the desicion to follow one pattern or another. If this doesn't feel right to you - don't do it.

dbrin
  • 15,525
  • 4
  • 56
  • 83