yadcf - Dynamic user selectable filter for DataTable -
is there way give option user select dynamically type of filter want applied 1 or more columns?
we using datatables jquery plugin display. i'm looking yadcf plugin use filtering(open other options well).
yadcf super versatile in being able define filters each column @ design time want ability user select filter type @ runtime. i'm looking yadcf code understand how pointers, ideas , helpful hints appreciated.
thanks,
ok did simple example allowing user define enable/disable filtering each column. may extend placing more dropdowns , asking type of filtering want.
fiddle
https://jsfiddle.net/ergec/6yjrrjyr/
html
col 1:<select class="colfiltering" data-colnumber="0"> <option value="">no</option> <option value="1">yes</option> </select> col 2: <select class="colfiltering" data-colnumber="1"> <option value="">no</option> <option value="1">yes</option> </select> <button id="inityadcf"> apply filters table </button> <br> <br> <br> <table id="table_id" class="display"> <thead> <tr> <th>column 1</th> <th>column 2</th> </tr> </thead> <tbody> <tr> <td>row 1</td> <td>2</td> </tr> <tr> <td>row 2</td> <td>1</td> </tr> <tr> <td>row 1</td> <td>10</td> </tr> </tbody> </table>
javascript
var mytable = $('#table_id'); mytable.datatable(); $("#inityadcf").click(function() { var colfiltering = []; $(".colfiltering").each(function() { var $that = $(this); if ($that.val()) { colfiltering.push({ column_number: $that.data("colnumber") }); } }); mytable.datatable().destroy(); mytable.datatable(); yadcf.init(mytable.datatable(), colfiltering); });
Comments
Post a Comment