javascript - toggle row with specific attribute in jquery datatable on click -


i'm new jquery datatable.

what i'm trying achieve is, toggle(hide/show) row of datatable having attribute named status_id value 9 13 on button click.

i have tried number 9, it's not working.

var dtable = $('#tbl_tasklist').datatable();  $(document).on('click', '.hide-tasks', function (e) {      e.preventdefault();      var row = dtable.row($(this).attr('status_id'));     if(row === '9') {         dtable.row().hide();     } }); 

there no hide() feature rows. trying specialized filter, create custom filter achieve want. here example of toggleable filter hide or shows <tr>'s status_id 9 or 13 :

$('#hide-tasks').on('click', function (e) {   //is checkbox checked?   if ($(this).is(':checked')) {     //add filter     $.fn.datatable.ext.search.push(function( settings, data, dataindex ) {       //always go through api when working datatables!       var status_id = parseint(table.row(dataindex).nodes().to$().attr('status_id'))       return !~[9,13].indexof(status_id)    })  } else {    //reset filter    $.fn.datatable.ext.search.pop()  }     //update table  table.draw() })   

demo -> http://jsfiddle.net/k1cz6rma/


Comments

Popular posts from this blog

wordpress - (T_ENDFOREACH) php error -

Export Excel workseet into txt file using vba - (text and numbers with formulas) -

Using django-mptt to get only the categories that have items -