variables in new DataTable

variables in new DataTable

danbuntudanbuntu Posts: 11Questions: 2Answers: 0

I'm trying to use a varible when defining my datatable options. This is to allow me to change is dynamically.

I have the following test case:

<code>
var paging = 'testttt';

let table = new DataTable('#resultstable', {
    bPaginate: paging
});

</code>

When this is outputted it's printing bPaginate: paging rather then bPaginate: testttt

Answers

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

    When this is outputted it's printing bPaginate: paging rather then bPaginate: testttt

    Please explain what you mean when you say outputted.

    Using the form bPaginate is from Datatables 1.9 and is deprecated. Datatbles uses camel case notation now. See the conversion doc. bPaginate is now the paging option. This particular option takes a boolean parameter not a string.

    See this test case demonstrating setting the paging parameter, via a variable, to true for the first table and false for the second table:
    https://live.datatables.net/hujobino/1/edit

    Kevin

Sign In or Register to comment.