diff --git a/README.md b/README.md index 0d294f4..52e0d69 100644 --- a/README.md +++ b/README.md @@ -9,19 +9,34 @@ HTML Structure: Item # Type + Price Item 1 Special + $10.00 Item 2 Not Special + $11.00 This plugin requires a `` for each column. The label for the `` will be replaced by a dropdown select menu containing all of the unique values present in that column. In the above example, selecting "Special" for the type column would hide Item 2, leaving only item 1. +Since we don't want to filter by things that only appear once (like price, maybe), we just add the class `skip-filter` to that column heading. + +For example: + +
+<tr>
+<th>Item #</th>
+<th>Type</th>
+<th class="skip-filter">Price</th>
+</tr> +
+ How To Use ------------------- It's simple. Just include ddtf.js (along with jQuery), and do: @@ -32,6 +47,8 @@ To use the options defined below, use the following syntax: ...more settings here } $('#myTable').ddTableFilter(options); + + Options ------------ @@ -48,6 +65,20 @@ For customization, the following parameters are available: * sortOpt: A boolean indicating whether or not to sort the options. This must be true for sortOptCallback to work. Defaults to true. * debug: A boolean indicating whether or not to run in "debug" mode. Debug mode displays performance data. * minOptions: Number of options required to show a select filter. Defaults to 2, meaning if a column only has one unique value, no select box will be shown (what would be the point?). +* firstOptionText: The first select option label text. Could be something like "All" or defaults to the column title. +* headingClass: Option for adding a `class` to the column heading for floating, styling, or just hiding. Defaults to no class and just `style="display:none;"` + + +Callback +------------ +The use case for the callback might be something like the following where we want to filter and then add-up all the filtered rows: + +
$('#myTable').ddTableFilter(options, function() {
+	// Callback stuff here
+	var sum = addColumns(); // pretend that f(x) sums visible column data or something
+	$('#myTable tfoot th:nth-child(n+1)').text(sum);
+});
+ Compatibility ------------------- diff --git a/ddtf.js b/ddtf.js index b25da1e..ddd0a38 100644 --- a/ddtf.js +++ b/ddtf.js @@ -1,6 +1,6 @@ (function($) { -$.fn.ddTableFilter = function(options) { +$.fn.ddTableFilter = function(options,callback) { options = $.extend(true, $.fn.ddTableFilter.defaultOptions, options); return this.each(function() { @@ -16,7 +16,12 @@ $.fn.ddTableFilter = function(options) { var selectbox = $('