How to reload multiple datatable at same time ?

How to reload multiple datatable at same time ?

xulprintxulprint Posts: 3Questions: 2Answers: 0
edited March 2022 in DataTables

Hi everyone,

I have 6 datatable in one page, i need to reload all tables at the same time when i change one of them !!
how can i do it ?

Answers

  • rf1234rf1234 Posts: 2,809Questions: 85Answers: 406
    edited March 2022

    I do it by calling a simple function passing an array of tables. Not sure whether you use Editor. If so you could use the "submitSuccess" event.

    function ajaxReloadTbls(tbls) {
        for (var i=0; i < tbls.length; i++) {
            tbls[i].ajax.reload(null, false) //stay on the same page!!
                   .columns.adjust()
                   .responsive.recalc();
        }
    }
    

    like this for example:

    editor_one
        .on('submitSuccess', function () {
            ajaxReloadTbls([dt_one, dt_two, dt_three, dt_four]);
        })
    
Sign In or Register to comment.