dt3 export issues

dt3 export issues

chboccachbocca Posts: 123Questions: 16Answers: 1
edited August 15 in Buttons

Hi Allan.

Started integrating dt3, thank you.

Amazingly smooth so far.

A minor issue is that there seems to be no screen message indicating how many rows are copied with Copy button, which I've grown accustomed to seeing in dt2.

A bigger issue is that when I try to exclude a column with the exportOptions{}, I get error below:

Error message: "Uncaught SyntaxError: Failed to execute 'matches' on 'Element': ':not(.label):visible' is not a valid selector"

If I just use ':visible', no problem.

Here is link to my test case: Export Selector Issue - dt3.0

Click Copy, function works but without message.

Click CSV - Visible, all good.

Click CSV - Visible Not Label, fails giving above error.

Only other issue so far is that your old plugin order.neutral() does not work with dt3. For now, I've just set that aside.

Let me know if code issue (or me).

Thank you again, c

Replies

  • chboccachbocca Posts: 123Questions: 16Answers: 1
    edited August 16

    Rewriting the selector seems to fix issue:

    exportOptions: { columns: [ ':not(.label)' ], columns: [ ':visible' ] }
    

    I've added a 4th button to test case ... Export Selector Issue - dt3.0

    Click CSV - Visible Not Label [Fixed], all good.

    Let me know if you support this approach.

    Thanks!

    c

  • chboccachbocca Posts: 123Questions: 16Answers: 1

    PS. I also updated the order.neutral() plug-in ...

    https://cdn.datatables.net/plug-ins/3.0.1/api/order.neutral().js

    My bad for not checking.

    Works now with dt3.

    Thank you!

    c

  • allanallan Posts: 65,927Questions: 1Answers: 10,973 Site admin

    Hi,

    {
      columns: [ ':not(.label)' ],
      columns: [ ':visible' ]
    }
    

    is the same as:

    {
      columns: [ ':visible' ]
    }
    

    i.e. you can't have two parameters with the same name in the object - the second will "win". So it might not be doing exactly what you expect at the moment.

    The lack of a :visible selector is a bit of a problem, and I'm not yet certain how to address that. I most certainly don't want to use a custom selector engine like jQuery does, but there does need to be a way to handle this. One option could be adding a class to hidden header elements, which would be the :visible part can be updated to be :not(.is-hidden) or something like that.

    Good to hear that you got order.neutral() working with the latest plugins.

    Allan

  • chboccachbocca Posts: 123Questions: 16Answers: 1

    Thank you. Bummer. As you noted, my earlier approach did not work in our production version.

    Followed your recommendation to add class to headers (columns) to be exported.

    I add 'export' class to all visible columns, then exclude as appropriate.

    Then,

    exportOptions: { columns: ['.export'] }
    

    Here is link to updated test case: Export Selector Issue - dt3.0 [rev1]

    Click Export, then CSV Visible Export [Fixed].

    It includes all visible columns but excludes the column with class label.

    More complex, but does the job ... I verified this approach now works on production version.

    Thank you!

    c

  • chboccachbocca Posts: 123Questions: 16Answers: 1

    couple quick follow ups ...

    1) note sure why fileName is coming out 'null' in csv export, even though it is specified with

    fileName: 'export_csv'
    

    2) do you intend to add back the screen message indicating how many rows are copied with Copy button?

    c

  • allanallan Posts: 65,927Questions: 1Answers: 10,973 Site admin

    1) It should be filename, not fileName. The docs have the correct name (although possibly is it wrong somewhere else?).

    2) Yes, that is a bug. Thanks for letting me know about it. I've committed a fix which will be in the next patch for Buttons, which I'll make to release it tomorrow.

    Allan

  • chboccachbocca Posts: 123Questions: 16Answers: 1

    thank you!

Sign In or Register to comment.