Iterating through buttons

Iterating through buttons

dkorobovdkorobov Posts: 1Questions: 1Answers: 0

I have n number of tables (with unique ids) on the table initialized with DataTables(). Each table has a set of the same buttons to be able to filter that particular table with the certain date ranges. No matter how i get the buttons i keep getting a list of all tables instances and then inside there i need to somehow figure out which one is mine and then call buttons() to get buttons from that instance.

here's some inconsistency. this gives me instance dt.table().node() but somehow dt.table().buttons() gives me all 4 tables instances with instance buttons somewhere in there. I would have to do something similar to this

dt.buttons('.quartertoggle').each(function(value, index){
// no clue why it needs to be this way? it seems to dump all the table instances at once
value.inst.s.buttons.forEach( b => {

Am I missing something here? Why inside my dt variable all of a sudden i get all the instances if i'm looking for buttons? Specifically how do i iterate though the button of a particular instance?

This question has an accepted answers - jump to answer


  • kthorngrenkthorngren Posts: 13,577Questions: 25Answers: 3,193
    edited June 7 Answer ✓

    There is a difference between dt.table().buttons() and dt.buttons(). Presumably you are initializing multiple tables at once, like this example, and assigning the APIs to the variable dt. Using dt.table() will return the first Datatable API. dt.table(1) will return the second Datatable. See the table() docs for more info.

    However dt contains the API for all the Datatables. dt.buttons() will return all the buttons for all the tables. See this example:

    The example shows one way to iterate the buttons for just one of the tables.


Sign In or Register to comment.