Is there a way to create a controller for specific xtypes/containers?

64 Views Asked by At

I have forms built with different components that load and edit the same records in different ways.

Overall, I have a viewController for these records which handles the loading and saving of the forms. All the forms have a 'load' and 'save' button which is handled in this 'recordController'.

However, because of the different containers I created that can be used to view the records, some paginated or expandable, I have functions that handle the buttons 'next page', 'prev page', 'expand info' contained in the recordController.

I want to remove these functions 'next page', 'prev page', and 'expand info' from the recordController and place them into controllers specific to the xtypes I made them for. This way, I can create components with the same functionality without duplicating the functions in the code.

I know I can put these functions into a 'masterController' that all other controllers inherit from, however as time goes on the masterController would grow and can become difficult to manage/change functionality of. Ideally neither controller inherits from the other.

Basically the concept of what I'm trying to do is:

Ext.define('CustomForm', {
     controller: 'recordController',
     items: [{
           xtype: 'tabpanel',
           controller: 'tabpanelController'
     }]
};

Obviously the above doesn't work, but if it did ideally function calls in the tabpanel would default to the tabpanelController before heading to the recordController, without the tabpanelController being a descendant of the record controller.

Is there a way to accomplish this concept?

0

There are 0 best solutions below