javascript - How to disable sorting on specific column while searching is functional -


i using datatable (http://www.datatables.net) in order desired functionality including sorting columns , searching within columns table heading individually. initializing follow returns api , searching functionality achieved.

$('#table2').datatable()

now problem when have disable sorting on checkbox , have use following line of code. $('#table2').datatable( { "aocolumndefs": [ { "bsortable": false, "atargets": [ 0 ] } ] } );

it apply sorting disabled on column search functionality within column doesn't work. there way can pass parameter in datatable({something}) in order disable sorting on first column or please me combine (api & jquery object) method in order achieve desired functionality. $('#table2').datatable(); $('#table2').datatable();

<table class="table table-striped draggable sortable datatable" id="table2"> <thead>     <tr>         <th class="text-center"> <input class="check_box_all no-sort" id="check_all" type="checkbox" title="check all"></th>         <th class="text-center">company name </th>     </tr> </thead> <tbody>     <tr class="odd gradex">         <td class="text-center"><input type="checkbox" class="check_box"></td>         <td class="text-center">med assets company</td>     </tr> </tbody> 

this snippet makes input field in table heading searching purpose

$('#table2 thead th').slice(3).each(function () {     var title = $('#table2 thead th').eq($(this).index()).text();         $(this).html('<input type="text" placeholder="' + title + '" />');  }); 

data table initialize

 var table = $('#table2').datatable({     "dom": 'c<"clear">lfrtip',     "spaginationtype": "full_numbers",}); 

applying search

 var tableresult = table.columns().eq(0); if (tableresult !== null) {     tableresult.each(function (colidx) {         $('input', table.column(colidx).header()).on('keyup change', function () {             table                     .column(colidx)                     .sort()                     .search(this.value)                     .draw();         });     }); } 

please check jsfiddle when check box checked totally mess https://jsfiddle.net/sxgd0thm/

$('#example').datatable( { "aocolumndefs": [   { "bsearchable": true, "atargets": [ 0,1,2,3,4,5 ] } ] } ); 

try "bsearchable" allowable column search


Comments

Popular posts from this blog

Magento/PHP - Get phones on all members in a customer group -

php - Bypass Geo Redirect for specific directories -

php - .htaccess mod_rewrite for dynamic url which has domain names -