Newbie: trying to get buttons to work using layout rather than dom.

Newbie: trying to get buttons to work using layout rather than dom.

sidsnotsidsnot Posts: 3Questions: 1Answers: 0
edited March 17 in Free community support

Hi,
Fairly new to web page programming so forgive my ignorance. I managed to cobble together a working implementation of datatables with buttons a few years ago to show/hide columns and now am trying to upgrade to the latest version. I can no longer get the buttons to show when moving from dom: 'Blfrtip' to layout:. Been playing around in the live environment but having no luck getting it going in there - can anyone see what I'm doing wrong? (I assume the buttons should still show even if they perform no function?)

https://live.datatables.net/wulivadu/1/edit

Thanks

This question has an accepted answers - jump to answer

Answers

  • kthorngrenkthorngren Posts: 21,330Questions: 26Answers: 4,951
    Answer ✓

    Take a look at the browser's console to see the error thrown:

    Uncaught TypeError: (intermediate value) is not a function

    You have the wrong syntax. You have this:

    var table = new DataTable('#example')({
    

    It should look like this:

    var table = new DataTable('#example', {
    

    Updated exampel:
    https://live.datatables.net/wulivadu/2/edit

    Kevin

  • sidsnotsidsnot Posts: 3Questions: 1Answers: 0

    Thanks for that. Duh. I did go back and paste in the example properly.

    Is there any way to have the buttons on top, and then have the pageLength immediately below them, as now it no longer appears?

    (The dark theme doesn't apply properly and the "paging" element is all awry but that currently works in my main site so I won't worry about that for now in this test)

  • sidsnotsidsnot Posts: 3Questions: 1Answers: 0
    edited March 17

    .

  • 3pwq13pwq1 Posts: 2Questions: 1Answers: 0

    Just change your layout to this:

    layout: {
        topStart: ['buttons', 'pageLength']
    },
    
Sign In or Register to comment.