Reset DOM on initComplete

Reset DOM on initComplete

jdadwilsonjdadwilson Posts: 127Questions: 30Answers: 1

I implemented the alphabetSearch feature across my site (www.txfannin.org). I have a small problem I hope someone can address.

It may be that the results of the query request for the table load produces less rows that the initial value of the lengthMenu array. On the initComplete I check the number of rows (table.rows().data().length) against a fixed value. If less than the value I hide the dataTables_paginate, filter, info, and length divs. Additionally, I would like to hide the alphabetSearch area but this does not have a defined id. The only way I can think to do what I want is to remove the 'A' for the Dom. How to do this?

Further, how can I compare the table.rows().data().length against the initial lengthMenu value, or even the current lengthMenu value?

TIA for your assistance
jdadwilson

Replies

  • allanallan Posts: 63,803Questions: 1Answers: 10,515 Site admin

    I would suggest the best way might be to simply add an id to the alphabet search's div.

    Further, how can I compare the table.rows().data().length against the initial lengthMenu value, or even the current lengthMenu value?

    Use page.info() to get paging information.

    Allan

  • jdadwilsonjdadwilson Posts: 127Questions: 30Answers: 1

    Allan -- thanks for your response. Adding the div did the trick. Using the page.info() helps with the second but does not totally answer my question. I would like to use something like this... if ( table.page.info().recordsTotal < num ) where num is the initial value of the lengthMenu or better the active value of the lengthMenu.

    Thanks for a great product and support
    jdadwilson

  • allanallan Posts: 63,803Questions: 1Answers: 10,515 Site admin

    I'm afraid I don't quite understand why it doesn't resolve it - would you not use:

    var info = table.page.info();
    
    if ( info.recordsTotal < info.length ) {
     ...
    }
    

    I assume your question is how to get num, in which case the length property should do it.

    Allan

This discussion has been closed.