What event to use AFTER the datatable is fully drawn

What event to use AFTER the datatable is fully drawn

faniefanie Posts: 3Questions: 1Answers: 0
edited June 14 in Free community support

Hi,

I'm actually searching for an event triggered when the Datatable is fully drawn.

I tried with the 'init.dt' and 'draw.dt' events but nothing...

The draw.dt is triggered after the init.dt, and my datatable is fully visible just some seconds after the trigger of the init.dt

Answers

  • colincolin Posts: 2,365Questions: 0Answers: 425

    Hi @fanie ,

    This is similar to another thread I just replied to. Take a look at the example here that I used in that thread. For the init to fire, you need to register the listener before the table is initialised,

    Cheers,

    Colin

  • faniefanie Posts: 3Questions: 1Answers: 0

    Hi,
    thanks for your reply.

    I register it before initialising my table.

    The only solution I have is that:

    $('#myTable')
    .on( 'init.dt', function() {
        //show nothing
        console.log('no access to: ' + $('.dataTables_scroll') );
        setTimeout(function(){
            //show element
            console.log('access to: ' + $('.dataTables_scroll') );
        }, 0);
    })
    .DataTable();
    

    which isn't really academic... and demonstrate there is only milliseconds to wait to have access to the element.

    So I think it may be because of the asynchronous stuff...

  • allanallan Posts: 48,053Questions: 1Answers: 6,898 Site admin

    That looks like it should work: http://live.datatables.net/kolofuqo/1/edit .

    Given that you are using dataTables_scroll I suspect you've removed your initialisation options - perhaps you are using Ajax? Can you link to a page showing the issue please, otherwise I'm afraid we are just guessing.

    Allan

Sign In or Register to comment.