PDA

View Full Version : ext4 mvc



drumforhim
9 Mar 2013, 7:15 AM
Hello everyone! Just started using-learning the "new" mvc architecture in extjs4 and i find it amazing. Ed and who else is there, you guies have done an amazing job!The refs array with it's get set functions,the getController function, and the views are only a fraction of what you 've done. I just have a question about code resusability. Let's say that in my application i have to have 20 grids. The grids must have tha same functionality.editors and a save button that sends updatedredcords,deleted records, and new records to the server.So my question is how can i make a grid controller that it's going to take care of all my grids. in common non-mvc world i would make a function and i would pass the fields and the function would take care of every grid. but with the new mvc arch it seems that i have to make a controller ,a model, a store and a view for every grid-entity of my application. Hope my question makes sense!

mitchellsimoens
10 Mar 2013, 8:59 PM
You should create a grid extension..


Ext.define('MyApp.view.grid.Abstract', {
extend : 'Ext.grid.Panel',
xtype : 'myapp-grid-abstract',

//...
});

Then in your controller you can do something like:


init : function() {
var me = this;

me.control({
'myapp-grid-abstract' : {
someevent : me.someFunction
}
});
}

I rarely use refs personally and they are in no use if you want to control 20 grids.