Changing Export Filename After Table Initialization

Changing Export Filename After Table Initialization

RossIVRossIV Posts: 1Questions: 1Answers: 0
edited March 2018 in Free community support

Is there any way to change the CSV/Excel button export filename after the table has already been initialized? I read the documentation which indicates you have to either set it at initialization or set it with a function callback specified at initialization. In my specific application, the data going into the table is variable and I'd want the filename to change based on user's selection (made after the table is initialized).

What I'm wondering is if there's any way with an API call to the DataTable object to set the filename, or any suggestions on the best way to go about doing this? I'd like to avoid re-initializing the table upon each user selection if at all possible.

If it helps, this is in a web application written with Laravel and VueJS. Vue is the main reason I can't use the callback for file name - the user's interaction is processed in Vue but the DataTable can't reach into the Vue realm to call a function or read the attribute(s) directly. Further, we've abstracted the base DataTable into a Vue component, so it's difficult to make individual initialization changes for one use of the component.

Debug: https://debug.datatables.net/iwerin

Edit: Apologies, I meant to post this in the Buttons sub-forum.

Answers

  • colincolin Posts: 15,235Questions: 1Answers: 2,597

    Hi RossIV,

    This example shows how the export file name for the XLS button can be set by a function. This may get you going in the right direction.

    Cheers,

    Colin

This discussion has been closed.