hhurz / tableExport.jquery.plugin

jQuery plugin to export a html table to JSON, XML, CSV, TSV, TXT, SQL, Word, Excel, PNG and PDF
MIT License
984 stars 714 forks source link

Table export providing download button for defaults.format instead of format that was selected in bootstrap table #366

Closed nvcastelli closed 1 year ago

nvcastelli commented 1 year ago

I'm using tableExport with a bootstrap table and am trying to figure out why tableExport is only providing links to the default format values. Debugging myself I am seeing the tableExport method is called with the correct parameter but am unsure how it gets switched to the 3 default formats.

Attached is an image of what I'm seeing after selecting export as JSON. Screen Shot 2023-05-24 at 2 50 32 PM

Please let me know if there's any other additional information that I can provide.

EDIT: Additionally, when selecting the download type the buttons appear on the bottom of the table instead of just downloading the type selected in the dropdown. I'm only able to download using those buttons on the bottom of the table, is that intentional?

hhurz commented 1 year ago

Sorry for this late reply. This seems to be an issue related to bootstrap-table. Please ask your question on their page again.

nvcastelli commented 1 year ago

Just to confirm, in the tableexport.js file, I see that the proper option for download is being passed into the file from the bootstrap-table-export.js file, in this case 'json' in the image shared below . Somewhere in the tableexport.js file the code is defaulting to the defaults.format of formats: ["xlsx", "csv", "txt"], at around line 153. Could you explain why this isn't from functionality in tableexport.js when it looks like it's receiving the correct file type from the bootstrap table? Screen Shot 2023-06-06 at 10 47 20 AM

My expectation is that filetype would be determined from the type property but it looks like it's pulling it from the formats array property instead, thanks.

hhurz commented 1 year ago

Your expectation is fulfilled: in line 244 of tableexport.js you will find the statement $.extend(true, defaults, options);, which ensures that the values defined in the passed options parameter overwrite the corresponding values of the defaults object. The following code will then only work with the defaults object. Thus the passed format type is taken over as expected.

FYI, the three buttons that appear at the bottom of your table are not displayed by the Tableexport plugin. All the UI stuff you observe is provided by the bootstrap table export.

nvcastelli commented 1 year ago

Thank you for the explanation. With this, I was able to see what I was doing incorrectly. It was an issue with my infrastructure and how I was referencing the plugin. Thank you for your time, now to get the plugin to working with XLSX 😁