How to add option in action menu of module listview - 7.x

Hi

how to add option in action menu of module listview like below

Screenshot from 2016-04-11 11:28:43.png

  • Hi Mehul,

    You have to add button in recordlist.php.

    Copy file from clients/base/views/recordlist/recordlist.php

    And place file in below path.

    File Path should be custom/modules/{module-name}/clients/base/views/recordlist/recordlist.php.

    Make changes in $viewdefs array.So that recordlist definition will pick from module specific,instead clients/base/views/recordlist/recordlist.php or modules/{module-name}/clients/base/views/recordlist/recordlist.php

    And add your button array next to export button in that file.

    Button array should be something similar like

     array(
                    'name' => 'test_list_button',
                    'type' => 'button',
                    'label' => 'LBL_TEST_LIST_BUTTON',
                    'events' => array(
                        'click' => 'list:testlistbutton:fire',
                    ),
                    'acl_action' => 'export',
                ),
    

    acl_action you can specify base on your case.

    In recordlist.js

    ({
        extendsFrom:'RecordlistView',
        initialize:function(options){
            this._super('initialize',[options]);
            this.context.on('list:testlistbutton:fire',this.testlistbuttonFunc,this);
        },
        testlistbuttonFunc:function(){
              console.log("Test button in list view gets called");
              var massCollection = this.context.get("mass_collection");
              var id_array = [];
              massCollection.each(function(data){   
                    id_array.push(data.id); //pushing ids of selected
              });
        }
    })
    

    Hope this Helps.