DT2.0 and Excel BTN 3.0.1 - Columns rearrange with headers not working

DT2.0 and Excel BTN 3.0.1 - Columns rearrange with headers not working

awariatawariat Posts: 7Questions: 3Answers: 0

Hi, I have updated to DT2.0, and I've noticed when I export to excel my columns data is OK, but the headers are in positions like in my DT.
example:

exportOptions: { columns: [28, 1, 2, 7, 8, 14, 15, 16, 17],...

The data is from column 28 but header from column 0

Kind regards
Jack

Answers

  • allanallan Posts: 63,482Questions: 1Answers: 10,467 Site admin

    Yes, there appears to be a problem with a custom column ordering of the data due to the complex header support I'm afraid. I've got that on my list to look at.

    I'm not yet sure if I consider it a DataTables bug or Buttons / export bug! DataTables doesn't provide the column header data in anything but data order, which is by design and anything else might be difficult. But it can do out of sequence data.

    Allan

  • awariatawariat Posts: 7Questions: 3Answers: 0

    Thank you for your comment.
    I plan to do it this way below. Have you better idea?

    format: {
         header: function (headerText, index, node) {
                if (index == 0) {
                      return 'Comments';
                     }
                      else {
                         eturn headerText;
                            }
                        }
                    }    
    
  • allanallan Posts: 63,482Questions: 1Answers: 10,467 Site admin

    Not really - other than for me to resolve the underlying question :)

    If that works for you, got with that for now.

    Allan

  • awariatawariat Posts: 7Questions: 3Answers: 0

    OK thank you.
    If it helps, I updated from /dt-1.11.3/b-2.0.1/ where all was working OK.

Sign In or Register to comment.