Skip to content

Instantly share code, notes, and snippets.

@annuman97
Created March 26, 2022 09:34
Show Gist options
  • Save annuman97/d2b64626fdeb08aef76877913cc5bfeb to your computer and use it in GitHub Desktop.
Save annuman97/d2b64626fdeb08aef76877913cc5bfeb to your computer and use it in GitHub Desktop.
/*Count rows of the table (it will work if filter is applied)*/
function runAll(){
var rowCount = FooTable.get('#footable_534').toJSON().rows.length;
var fixCount = FooTable.get('#footable_534').toJSON().rows.length;
var $countWrapper = $table.parent();
$countWrapper.prepend('<div class="remove">Total <span>' + rowCount + "</span> data found</p>");
$table.on('postdraw.ft.table', function(e, ft) {
jQuery('.remove').remove();
var rowsCount = ft.rows.array.length;
$countWrapper.find('.table_info_count .current_count').html(rowsCount + " of " + fixCount);
});
}
runAll();
$table.on('after.ft.paging', function (e) {
e.preventDefault();
runAll();
});
$table.on('after.ft.filtering', function (e) {
e.preventDefault();
runAll();
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment