UNPKG

patternfly

Version:

This reference implementation of PatternFly is based on [Bootstrap v3](http://getbootstrap.com/). Think of PatternFly as a "skinned" version of Bootstrap with additional components and customizations.

42 lines (36 loc) 1.37 kB
/** * Utility to show empty Table View * * @param {object} config - Config properties associated with a Table View * @param {object} config.data - Data set for DataTable * @param {string} config.deleteRowsSelector - Selector for delete rows control * @param {string} config.restoreRowsSelector - Selector for restore rows control * @param {string} config.tableSelector - Selector for the HTML table */ var emptyTableViewUtil = function (config) { var self = this; this.dt = $(config.tableSelector).DataTable(); // DataTable this.deleteRows = $(config.deleteRowsSelector); // Delete rows control this.restoreRows = $(config.restoreRowsSelector); // Restore rows control // Handle click on delete rows control this.deleteRows.on('click', function() { self.dt.clear().draw(); $(self.restoreRows).prop("disabled", false); }); // Handle click on restore rows control this.restoreRows.on('click', function() { self.dt.rows.add(config.data).draw(); $(this).prop("disabled", true); }); // Initialize restore rows if (this.dt.data().length === 0) { $(this.restoreRows).prop("disabled", false); } }; // Initialize empty Table View util new emptyTableViewUtil({ data: dataSet, deleteRowsSelector: "#{{include.actionId1}}", restoreRowsSelector: "#{{include.actionId2}}", tableSelector: "#{{include.tableId}}" });