Bootstrap-table how to use exportOptions

user1534019 picture user1534019 · Oct 3, 2015 · Viewed 14.2k times · Source

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?

Answer

wenyi picture wenyi · Oct 13, 2015

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/