Pricing changes are coming in January. Contact our Sales team to secure the current price for your desired license.

export csv field separator editable from frontend

Answered
riccardo asked on March 18, 2024

HI,
they ask us to be able to change the fieldsseparator when exporting to csv directly from the frontend.
Is it possible? And if so, how?
 
Thanks
 
Riccardo
 
 

3 answers

Public
Solomiia Andrusiv Solomiia Andrusiv Flexmonster March 19, 2024

Hello, Riccardo!
 
Thank you for reaching out to us.
 
Kindly note that it is possible to create your own UI control that would allow users to choose the desired fieldSeparator. Here is the brief approach:
 
1. Create your own UI control, e.g., <select> :

<select id="CSVFileSeparator">
    <option value=",">,</option>
    <option value=";">;</option>
    <option value=":">:</option>
    <option value="|">|</option>
    <option value="/">/</option>
</select>

 
2. Add customizeToolbar handler to beforetoolbarcreated event when creating Flexmonster instance:

const pivot = new Flexmonster({
  container: "#pivot-container",
  toolbar: true,
  beforetoolbarcreated: customizeToolbar,
  report: //your report
});

 
3. In the customizeToolbar() function, find "fm-tab-export-csv" tab and extract the fieldSeparator from your control:

exportToCSVTab.handler = () => {
      const fieldSeparator = document.getElementById('CSVFileSeparator').value || ',';
      this.pivot.exportTo("csv", {
        fieldSeparator: fieldSeparator
      })
    }

 
We have prepared a JSFiddle example for illustration: https://jsfiddle.net/flexmonster/7mau1cq5/.
You can read more about customizing the Toolbar in our docs: https://www.flexmonster.com/doc/customizing-toolbar/.
 
Hope you will find our answer helpful.
 
Kind regards,
Solomiia

Public
Solomiia Andrusiv Solomiia Andrusiv Flexmonster March 26, 2024

Hello, Riccardo!

Hope you are having a great week.

Our team is wondering if you had some time to check our previous response. Could you please let us know if the provided example for editing the CSV field separator from the client side was helpful?

Looking forward to hearing your feedback.

Kind regards,
Solomiia

Public
Solomiia Andrusiv Solomiia Andrusiv Flexmonster April 2, 2024

Hello, Riccardo!

Hope you are doing well.

Just checking in to ask if our example for editing CSV field separator from the client side was helpful.

Looking forward to hearing your feedback.

Kind regards,
Solomiia

Please login or Register to Submit Answer