Redraw different dataTable after updating other

Redraw different dataTable after updating other

dougguthriedougguthrie Posts: 10Questions: 7Answers: 0

I have two datatables on one page. After updating one I would like to see the results also appear in the second one. Is this possible?

I've been playing around with the draw() method as well as drawCallback. I'm not sure if I'm on the right track.

Code example below:

constraintEditor = new $.fn.dataTable.Editor( {
  ajax: {
    edit: {
      url: "/clients/aps/update",
      type: "PUT",
      data: function (d) {
        return JSON.stringify(d);
      },
      drawCallback: function ( settings ) {
        accountTable.draw();
      }
    }
  }

This question has an accepted answers - jump to answer

Answers

  • allanallan Posts: 61,635Questions: 1Answers: 10,092 Site admin
    Answer ✓

    It depends a little on your configuration - for example are your table's Ajax loaded, server-side processing or something else? If you can't link to a test case showing the issue, can you use the debugger to give us a trace?

    In the most common case, if you want to update a second table once another has been updated, use ajax.reload() inside an Editor submitComplete event handler - e.g.

    editor.on( 'submitComplete', function () {
      table2.ajax.reload();
    } );
    

    Allan

  • dougguthriedougguthrie Posts: 10Questions: 7Answers: 0

    My table is ajax loaded and this example fit my situation perfectly. Thank you again for your help!

This discussion has been closed.