• Resolved raivokaldma

    (@raivokaldma)


    Hello,

    is it possible make DataTables Buttons Excel, PDF, CSV .. download “Save As” automatic filename generated like this: “Page_name”-“table_name”-“table_description”-“site_name”.abc
    at moment the file name is generated from a page name and site name.

    (sorry my english)

    Best regards

    The page I need help with: [log in to see the link]

Viewing 9 replies - 1 through 9 (of 9 total)
  • Plugin Author Tobias B?thge

    (@tobiasbg)

    Hi,

    thanks for your post, and sorry for the trouble.

    The DataTables Buttons JavaScript library does offer a filename option here, see https://datatables.net/reference/button/csv
    This could be used inside a “Custom Command” in TablePress, and would then allow you set a new name. I don’t see a way to automatically fill that with a name like in your example though, sorry.

    Regards,
    Tobias

    Thread Starter raivokaldma

    (@raivokaldma)

    Hi,

    thnk You!

    Unfortunately I can’t use the “Custom Command” field. If I use this option, all the buttons are gone.
    And then dev tools shows javascript error – (index): 7 Uncaught SyntaxError: Unexpected string.
    Can you help in this regard?

    I also found such a guide, but I also got into trouble with it – https://www.datatables.net/extensions/buttons/examples/html5/filename.html

    WP 5.6

    Best Regards,
    Raivo Kaldma

    Plugin Author Tobias B?thge

    (@tobiasbg)

    Hi,

    what exactly have you added to the “Custom Commands” field? ??

    Regards,
    Tobias

    Thread Starter raivokaldma

    (@raivokaldma)

    Hi,

    i tried many different examples.. ??
    1. this:

    $(document).ready(function() {
        $('#example').DataTable( {
            dom: 'Bfrtip',
            buttons: [
                {
                    extend: 'excelHtml5',
                    title: 'Data export'
                },
                {
                    extend: 'pdfHtml5',
                    title: 'Data export'
                }
            ]
        } );
    } );
    -----
    2. this:
    ---
    $('#myTable').DataTable( {
    buttons: [
            {
                    extend: 'excel',
                    //Name the Excel
                    filename: 'Laulukoorid-Naiskoorid.xlsx',
                    text: 'Customized Excel',
    
                    
            }
    	    ]
    } );
    ----
    3. this:
    ---
    $('#myTable').DataTable( {
    buttons: [
            {
                    extend: 'excelHtml5',
                    //Name the Excel
                    filename: 'Laulukoorid-Naiskoorid.xlsx',
                    text: 'Customized Excel',
    
                    
            }
    	    ]
    } );

    —–

    I triend other samples too.. nothing

    Maybe i do something wrong …

    Regards,
    Raivo

    Thread Starter raivokaldma

    (@raivokaldma)

    and shortcode on the page looks like this:
    [table id=5 responsive="collapse" automatic_url_conversion=true automatic_url_conversion_new_window=true datatables_buttons="excel,pdf" /]

    Plugin Author Tobias B?thge

    (@tobiasbg)

    Hi,

    ah, ok. Inserting the full JS code is too much. You just need the command inside. Please try

    "buttons": [
      {
        "extend": "excel",
        "filename": "Laulukoorid-Naiskoorid.xlsx",
        "text": "Customized Excel"
      },
      {
        "extend": "pdf",
        "filename": "Laulukoorid-Naiskoorid.pdf",
        "text": "Customized PDF"
      }
    ]

    Regards,
    Tobias

    Thread Starter raivokaldma

    (@raivokaldma)

    YESS!!!! ??

    i tried the same before but then i didn’t have quotes and then the code didn’t work.

    Now it works the way I wanted!

    Best regard!
    Raivo

    code witout quotes:
    buttons: [
    {
    extend: ‘excel’,
    filename: ‘Laulukoorid-Naiskoorid.xlsx’,
    text: ‘Lae alla Excel’
    }
    ]

    Thread Starter raivokaldma

    (@raivokaldma)

    Great support!
    Thank You!

    PS! Rated and Doanted ??

    Plugin Author Tobias B?thge

    (@tobiasbg)

    Hi,

    no problem, you are very welcome! ?? Good to hear that this helped!

    Best wishes,
    Tobias

Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘DataTables Buttons Save As file name’ is closed to new replies.