Custom subpanel row action

Hi . All

i want to custom sugarcrm 7.9 subpanel action row add link for generate or download subpanel to PDF format.

This is the screen looks like.

i want custom add the link download PDF in the action row edit and unlink, and when user click data in subpanel can download as PDF format . Actually i am just try to add action button top-panel following this link SugarCRM7 HOW TO:  Manipulate Subpanel Top Buttons (Actions)  but when i am override the subpanel top-panel is gone. 

any solution for my issue 

1. add subpanel row action for download PDF 

2. generate subpanel module data to PDF format 

thanks

regards Eka Indra

Francesca Shiekh Alex Nassi Madalina Papacica

rowaction sugar 7.9.0

  • Hello Eka Indra

    To add a new button you needs to do a customization of the supanel-list view metadata.

    1.- Copy the file clients/base/views/subpanel-list/subpanel-list.php into a custom file

    2.- Add the new option on 'actions' array key, like:

    ...
    'actions'=>array(

    ......

    array(

    'type' => 'rowaction',

    'icon' => 'fa-eye',

    'event' => 'list:pdfbtn:fire',

    'label' => 'LBL_PDF_BUTTON',

    ),

    )

    3.- Add the label LBL_PDF_BUTTON to language files.
    4.- To handle the click event on your custom option customize the controller file clients/base/views/subpanel-list/subpanel-list.js

    Example:

    How to add a custom action into subpanel row actions · GitHub 

    I hope help you, Regards.

  • Hi Ceser,

    Thanks you for reply and your suggest is very help and now my issue number 1 is done and working fine .

    so you have any suggest for second issue which is to print or generate data table in subpanel to PDF format .

    i hope anybody and you Cesar Obed Gonzalez N. can help me 

    many thanks 

    regards Eka Indra

  • Hello Eka Indra

    I had a similar task ( print a PDF template from a custom button), I found the function that makes the magic for the record view.

    The field 'pdfaction' has the solution ( clients/base/fields/pdfaction/pdfaction.js)

    On your controller do the following...

    1.- Add a listener to custom button event:

    events: {
            'click [data-action=download]': 'downloadClicked',
        },

    2.- Create the functions to handle the event:

    /**
         * Handles download pdf link.
         *
         * Authenticate in bwc mode before triggering the download.
         *
         * @param {Event} evt The `click` event.
         */
        downloadClicked: function(evt) {
            var templateId = this.$(evt.currentTarget).data('id');

            app.bwc.login(null, _.bind(function() {
                this._triggerDownload(this._buildDownloadLink(templateId));
            }, this));
        },

    /**
         * Download the file once authenticated in bwc mode.
         *
         * @param {String} url The file download url.
         * @protected
         */
        _triggerDownload: function(url) {
            app.api.fileDownload(url, {
                error: function(data) {
                    // refresh token if it has expired
                    app.error.handleHttpError(data, {});
                }
            }, {iframe: this.$el});
        },

    3.- Quick repair and rebuild.

    I hope this help you. Regards