AnsweredAssumed Answered

Add custom button on subpanel list and open a drawer with record view

Question asked by mickeytang mickeytang on Aug 12, 2015
Latest reply on Sep 2, 2015 by Alexandre Moulin
I read this article: http://www.insightful.com.au/sugarcrm-how-do-i/creating-custom-button-sugar-7/ and succeed to create a button on record view to open a drawer.
However, I want to move the button from record view to subpanel list like the following image
However, the drawer popped out but the layout and view is not rendered.


I will be glad if anyone can help.
I am using Sugarcrm 7.6 Enterprise

My source code:

/custom/modules/drawe_drawertest/clients/base/views/subpanel-list/subpanel-list.js
({    extendsFrom: 'RecordlistView',
    initialize: function(options) {
        app.view.invokeParent(this, {type: 'view', name: 'recordlist', method: 'initialize', args:[options]});
        this.context.on('button:count_contacts:click', this.count_contacts_code, this);
    },
    count_contacts_code: function() {
                var AcctID = this.model.get('id');
                app.api.call('GET', app.api.buildURL('drawe_drawertest2/' + AcctID + '/count_contacts'), null, {
                        success: function(data) {
                                app.drawer.open({layout:'count-contacts',context:{totalContacts: data}});
                        },
                        error: function(error) {
                                app.alert.show("server-error", {
                                        level: 'error',
                                        messages: 'ERR_GENERIC_SERVER_ERROR',
                                        autoClose: false
                                });
                                app.error.handleHttpError(error);
                        }
                });
  }
})
Other files are exactly the same as the example in http://www.insightful.com.au/sugarcrm-how-do-i/creating-custom-button-sugar-7/

Outcomes