Question regarding copy options; customize, title and messageTop/Bottom

Question regarding copy options; customize, title and messageTop/Bottom

hm123hm123 Posts: 84Questions: 27Answers: 1
edited August 2017 in Free community support

I read about this from here:

https://datatables.net/reference/button/copy

The description of these options are as follows:

customize :
Function that can be used to modify the contents of the exported data. The function takes two parameters, the data as configured by the button and the button's configuration object. The value that the function returns is the value that will be used for the export.

This can be particularly useful if you wish to add a company header or footer, description data or any other information to the exported data.

title :
Title of the table that will be included in the exported data.

messageTop :
Message to be shown at the top of the table

messageBottom :
Message to be shown at the bottom of the table

I'm a little confused about the differences between these.

Do these do the same thing:

-Using the 'customize' option to add a header
-Using the 'title' option to include a title in the data
-Using the 'messageTop' option to show a message at the top

ie; add some predefined custom text at the top of the clipboard content?

This question has accepted answers - jump to:

Answers

  • tangerinetangerine Posts: 3,365Questions: 39Answers: 395

    -Using the 'customize' option to add a header
    -Using the 'title' option to include a title in the data
    -Using the 'messageTop' option to show a message at the top

    Those are three different things, as explained in the documentation. The best approach is to try them out and see the result.

  • allanallan Posts: 63,471Questions: 1Answers: 10,467 Site admin
    Answer ✓

    customize is really designed for you to be able to do anything you want to the output data. That could include adding titles, messages, modifying the exported data, whatever.

    The other options are present to make the most commonly performed actions easily accessible. If all you need to do is set a title, use the title option for example.

    Allan

  • hm123hm123 Posts: 84Questions: 27Answers: 1

    I've been meaning to try them out and see the result ever since I came across the documentation here:

    https://datatables.net/reference/button/copy

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

    And for a while I thought I was setting the JavaScript up wrong,

    But then some other users pointed out it wasn't working for them either:

    https://datatables.net/forums/discussion/44067

    So does that mean for now the only way to add the functionality of Title, messageTop and messageBottom is to use customize?

  • allanallan Posts: 63,471Questions: 1Answers: 10,467 Site admin
    Answer ✓

    Sorry! I've published the example and documentation prematurely. The excelHtml5 documentation notes that it is for v1.4.0+.

    I'll get the update for Buttons published shortly. Until then, if you want to try it out, use the nightly version.

    Allan

This discussion has been closed.