colOrder of Exported Columns

colOrder of Exported Columns

user3770935user3770935 Posts: 10Questions: 4Answers: 0

I have colReorder set, however I would like to have a set column order when the data is downloaded.

https://datatables.net/reference/api/buttons.exportData()

I cannot find an option to specify the column order in export settings.

https://jsfiddle.net/d6kwj9Lk/

Answers

  • user3770935user3770935 Posts: 10Questions: 4Answers: 0

    At the moment I am using another button to sort my columns before exporting:

                    {
                        extend: 'excel',
                        text: 'Download Excel',
                        exportOptions: {
                            columns: ':not(:eq(0))',//jquery to exclude column 0
                            modifier: {
                                selected: true,//download selected fields
                                filter: 'none',//ignor filter
                                search: 'none'//ignore search
                            }
                        }
                    },
                    {
                        text: 'Reset Column Order',
                        action: function(){
                            table.colReorder.order([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15], true);
                        }
                    },
    

    I was hoping to include a custom action on the excel button to carry out the reorder before download. Is this possible?

This discussion has been closed.