column().search() result

column().search() result

jimjimjimjim Posts: 5Questions: 3Answers: 0

Is it possible to know if column().search() returns true ( data is found matching) or false (data is not found).

Answers

  • allanallan Posts: 64,028Questions: 1Answers: 10,555 Site admin

    You could use the rows() method with any() to find this out:

    table.rows( { search: 'applied' } ).any();
    

    That would return true if there are results, false if not.

    Allan

  • jimjimjimjim Posts: 5Questions: 3Answers: 0

    Hi Allan, thanks for reply.
    I have this code:
    var oTable6 = $('#relations').DataTable();
    var select = oTable6
    .column( 0 ).search( '^'+inv+'$', true, false )
    .column( 1 ).search( '^'+yl+'$', true, false ).any();
    if( select == true)
    // something
    This does not work properly,select always is true
    Any idea about it?

  • jimjimjimjim Posts: 5Questions: 3Answers: 0

    now I tried the following code and works fine
    var select = oTable6
    .column( 0 ).search( '^'+inv+'$', true, false )
    .column( 1 ).search( '^'+yl+'$', true, false );
    var info = select.page.info();
    if( info.recordsDisplay>0)
    $('.active')[index].checked = true;

  • allanallan Posts: 64,028Questions: 1Answers: 10,555 Site admin

    // something This does not work properly,select always is true Any idea about it?

    I'll need to draw() the table before the new search terms take effect.

    Allan

This discussion has been closed.