Edit jQuery dataTables info -
i using jquery data table present table. have column has record active or inactive. want display count of number of column has value active & inactive right after shows showing 1 10 of 72 entries.
jquery
<script type="text/javascript"> $(document).ready(function () { $('#example').datatable({ "blengthchange": true, "paging": true, "spaginationtype": "full_numbers" , //for different paging style "scrolly": 400, // scrolling "jqueryui": false, //enabling jquery ui(user interface) "lengthmenu": [[30, 50, 100, -1], [30, 25, 50, "all"]], drawcallback: function (settings) { var api = this.api(); // number of rows, remove page:current if want number of rows in entire dataset var count = api.rows({ api: $('#example tbody tr td[value="active"]') }).data().length; // takes count , appends in span tag datatables pageinate div element $('<span id="active_rows"></span>').html(count + ' rows').appendto($('.datatables_info')); } }); }); </script>
i add unique #active
element .datatables_info
:
dom: 'lfrt<"info"i<"#active">>p',
then use drawcallback
drawcallback: function() { var active = 0; this.api().rows({'filter':'applied'}).every(function() { if (this.data().active == 'active') active++ }) $('#active').html(active+ ' active ...'); }
demo -> http://jsfiddle.net/3dmpwokd/
note: if using dom-based table, evaluate example this.data()[2]
instead of this.data().active
.
i have added css, dont know how want present info
.datatables_info { float: left !important; clear: none !important; } #active { display: inline-block; margin: 12px; }
Comments
Post a Comment