What is going on?

What is going on?

julez247julez247 Posts: 6Questions: 2Answers: 0

I just used your Download Builder, put it into my code and it doesnt work..
The table itself works, but the export button is not there. I can't find any real documentation about this.
I don't get it, what is this download builder for if it just doesnt work at all?
Same for all other datatable options.. all i get is a standard datatable..

My code is attached..

I've also seen this issue on several sites like "Form Generators" for datatables.. Only standard configurations. No datatable options are applied. What's wrong?? Is ur cdn down?

This question has an accepted answers - jump to answer

Answers

  • kthorngrenkthorngren Posts: 21,325Questions: 26Answers: 4,949
    edited November 2023

    I don't get it, what is this download builder for if it just doesnt work at all?

    The Download Builder doesn't build the config for you. It is meant to generate the proper libraries and styling includes for the options you select. There are many examples and docs for most features and the extensions, like buttons, to help with your configurations.

    The table itself works, but the export button is not there. I can't find any real documentation about this.

    The buttons docs can be found under the Extensions link on the left of the page. They are here. The Displaying the Buttons section shows two ways the buttons can be displayed. Also you can look at the examples and specifically a BS5 example.

    You will want to apply Bootstrap 5 table classes to the table tag to get thing like borders, etc. Click the HTML tab of the BS5 example for an example.

    Kevin

  • julez247julez247 Posts: 6Questions: 2Answers: 0

    I know. I've done this. As you can see in my code. Still doesnt output anything.

  • kthorngrenkthorngren Posts: 21,325Questions: 26Answers: 4,949
    edited November 2023

    You haven't followed the instructions to display the buttons. Look at the BS5 example. I added the code to display the buttons here:

            $(document).ready( function () {
                var table = $('#myTable').DataTable( {
                    buttons: [
                        {
                            extend: 'pdf',
                            text: 'Save current page',
                            exportOptions: {
                                modifier: {
                                    page: 'current'
                                }
                            }
                        }
                    ]
                } );
    
                table.buttons().container()
                   .appendTo( '#example_wrapper .col-md-6:eq(0)' );
            } );
    

    Note the addition of var table = to line 2.

    Kevin

  • kthorngrenkthorngren Posts: 21,325Questions: 26Answers: 4,949
    Answer ✓

    Sorry just noticed the incorrect selector in line 17. It should be this to match your table ID:

    .appendTo( '#myTable_wrapper .col-md-6:eq(0)' );
    

    Kevin

  • julez247julez247 Posts: 6Questions: 2Answers: 0

    thank you Kevin, I got it working but I'm stuck on another thing and I can't figure it out. Would you mind taking a look at my recent question? I would really appreciate ur help.

Sign In or Register to comment.