Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Bootstrap-table how to use exportOptions

I want to change the filename that is used when using the Table Export extension. I know I can use the exportOptions to add {fileName:'custom_file_name'}. But I don't know where to put this.

I tried:

data-export-options="{fileName:'custom_file_name'}"

and I tried to add as a method:

$('#table').bootstrapTable('exportOptions', {fileName: 'custom_file_name'})

But then I get an error: Uncaught Error: Unknown method: exportOptionsenter code here

What am I missing?

like image 381
user1534019 Avatar asked Oct 03 '15 19:10

user1534019


2 Answers

You can add the following as a html table attribute:

data-export-options='{"fileName": "desired filename here"}'

Make sure you have the proper quotes and that the key is fileName with camelCase.

like image 45
Timmy Avatar answered Sep 25 '22 07:09

Timmy


Use like this:

$('#table').bootstrapTable({
    exportOptions: {
        fileName: 'custom_file_name'
    }
});

Now we do not support via data-attributes, docs: http://bootstrap-table.wenzhixin.net.cn/extensions/#table-export.

Example: http://jsfiddle.net/wenyi/e3nk137y/3365/

like image 154
wenyi Avatar answered Sep 26 '22 07:09

wenyi