Suggestion: Allow function in dt.draw() calls

Suggestion: Allow function in dt.draw() calls

CaptainPalapaCaptainPalapa Posts: 1Questions: 0Answers: 0

Would be GREAT to see the ability to pass a function with any draw() commands. Obviously, one would expect the "main" drawCallback function to fire (as defined on the table setup), but the ability to add another function to run from a specific draw() call would be great. (Or maybe allow a second boolean parameter to prevent the primary drawCallback() from firing.)

For example, I might be editing a row (not live edit, but like in a modal, changing a record status), and then I'm returning the results to refresh a given row. I might want to "do something" after my .draw() call is made. Like thus: dt.row(0).data(oNewData).draw(function(){ alert('refreshed your row');}); If the function() could support params that would be added when fired from Datatables, such as a pointer to the table, etc., that would be great too. (Much like the column render() functions have implicit arguments that are passed.)

Replies

  • allanallan Posts: 63,540Questions: 1Answers: 10,476 Site admin

    I would suggest just using the one() method and the draw event. For example:

    table
      .one( 'draw', function () {
        console.log( 'my draw callback' );
      } )
      .draw();
    

    Allan

This discussion has been closed.