Is there a way toi hide a hidden value in the CSV file

Is there a way toi hide a hidden value in the CSV file

murday1983murday1983 Posts: 33Questions: 13Answers: 0

I have a download CSV button which is working and is currently not downloading certain columns (this is working fine and not the issue), the issue im having is, as I'm in the UK my date columns are in formatted as 'DD/MM/YYYY' and for the sorting to work correctly, i have a hidden span before my formatted date value which displays the date as 'YYYY/MM/DD' (again, this is working fine) BUT when i download as a CSV, it has both values in it so i was wondering if its possible to stop this

Example code

columns: [
            {
                data: null, width: '100px', title: 'Submitted',

                render: function (data) {
                    return '<span class="date">' + data.created + '</span> ' + data.created_formatted
                }
            },

And the date in the CSV

,"2024/07/06 06/07/2024",

The '2024/07/06' is the hidden span, and I want to hide it in the CSV file if possible

Answers

  • allanallan Posts: 65,298Questions: 1Answers: 10,827 Site admin
    edited October 30

    Two options:

    1. Use orthogonal data for the export
    2. Use a formatting function to strip the part you don't want.

    I'd say that since you have a rendering function, use the orthogonal approach - e.g.

    render: function (data, type) {
      if (type === 'export' || type === 'type' || type === 'sort') {
        return data.created;
      }
    
      return '<span... ';
    }
    

    Note that I've added checks for type and sort as well, which would allow the ordering in the table to work for the ISO detected date column.

    Allan

Sign In or Register to comment.