How to catch dataTables before rendering

How to catch dataTables before rendering

jdadwilsonjdadwilson Posts: 127Questions: 30Answers: 1
edited March 2014 in General
One of the modules in my web-app allows the user to scroll by months to filter records from the database. For some months there may be no records. Is there a way to catch dataTables before the table is rendered so that it will not display the header and the its 'No data available for table' message and I can simply add a message such as 'No records found for the selected month'

jdadwilson

Replies

  • jdadwilsonjdadwilson Posts: 127Questions: 30Answers: 1
    I figured it out. I set the table and the no records message in two separate divs which are hidden on the table load function. Then in the fnInitComplete I do the following...

    'fnInitComplete': function(oSettings, json) {
    if ( this.fnGetData().length === 0 ) {
    $('#noRecords').show();
    } else {
    $('#invTable').show();
    }

    Works great.
    jdadwilson
This discussion has been closed.