Sub buttons in Angular dataTables

Asked

Viewed 184 times

1

I’m using the Datatable plugin (https://l-lin.github.io/angular-datatables). And I need to make the export buttons to be sub-keys,where there will be an export icon and clicking this will be listed ( below ) the options ( CSV, PRINT, XLS).

It follows below the code I am using, but the same does not work the subitens, but the main button yes.

$scope.dtOptions = DTOptionsBuilder.newOptions()
            .withDOM('<"html5buttons"B>lTfgitp')
            .withButtons([
                'copy',
                'print', 
                {'sExtends': 'collection',
                 'sButtonText': 'Save',
                 'aButtons': ['csv', 'xls', 'pdf']
                }
            ])
            .withOption('info',false)
            .withOption('lengthChange',false);
    }

Thanks for your help.

1 answer

1

It follows the way I solved:

$scope.dtOptions = DTOptionsBuilder.newOptions()
            .withLanguageSource('js/plugins/dataTables/pt.json')
            .withDOM('<"html5buttons"B>lTfgitp')
            .withButtons([
                { extend:'collection', text: '<i class="fa fa-download"></i>', buttons: ['copy', 'csv', ] }, 
                { text: '<i class="fa fa-cog"></i>' }
            ])
            .withOption('info',false)
            .withOption('lengthChange',false);
    }

Using the withButtons, added an object containing the extend 'Collection', text which is the displayed text and Buttons where will be listed the subitens.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.