Set order for Export to Excel/PDF

Set order for Export to Excel/PDF

SethSeth Posts: 2Questions: 1Answers: 1

My data is returned in the correct order for export, but when displayed, it does reverse it currently (via order: [[x, desc]], and users can reorder it in the display via the column headers. I'd like the export options to be able to use the initial data order, and have the display sorting not change that.

I've searched and not found anything that seems it might work. I've tried several options including specifying Export options, toyed with a Sort setting in the customize options, although the sort field is a visible: false and I'm not exporting non visible fields, I read up on orthagonal, and I've not yet grok'd that, and being a javascript and jquery noobie having some trouble knowing where to go from here.

I considered having two different objects with the same data, but I'm not sure whether that is even possible, nor how to even clone an object rather than establish another reference to the original.

This question has an accepted answers - jump to answer

Answers

  • allanallan Posts: 61,822Questions: 1Answers: 10,129 Site admin

    I'd like the export options to be able to use the initial data order, and have the display sorting not change that.

    Use the selector-modifier's order option, set to be index.

    The selector modifier can be set through the exportOptions option parameter of the excelHtml5 and pdfHtml5 button types.

    Allan

  • SethSeth Posts: 2Questions: 1Answers: 1
    edited November 2017 Answer ✓

    Thanks Allan,

    After the hint, and some digging through the buttons code, I found I needed to wrap that in a modifier "tag" before it would work.

         exportOptions: {
                         columns: ':visible',
                         modifier: { order: 'index' }
                      },
    
    

    It did help me understand a little better about what is going on, although I do still get lost very quickly.

This discussion has been closed.