From 3727536bf3eec353cb770db5a46cea856fcd3247 Mon Sep 17 00:00:00 2001 From: James Silberbauer Date: Mon, 24 Jun 2013 21:46:42 +0200 Subject: [PATCH 1/8] sortAvailable option. Defaults to true. When false the sort ascending and descending menu items are not available. Set to false when using slick grid's multi column sorting. --- ext.headerfilter.js | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/ext.headerfilter.js b/ext.headerfilter.js index 62841cf..69ebecb 100644 --- a/ext.headerfilter.js +++ b/ext.headerfilter.js @@ -23,7 +23,8 @@ buttonImage: "../images/down.png", filterImage: "../images/filter.png", sortAscImage: "../images/sort-asc.png", - sortDescImage: "../images/sort-desc.png" + sortDescImage: "../images/sort-desc.png", + sortAvailable: true }; var $menu; @@ -99,6 +100,7 @@ } function showFilter(e) { + e.stopPropagation(); var $menuButton = $(this); var columnDef = $menuButton.data("column"); @@ -124,8 +126,10 @@ $menu.empty(); - addMenuItem($menu, columnDef, 'Sort Ascending', 'sort-asc', options.sortAscImage); - addMenuItem($menu, columnDef, 'Sort Descending', 'sort-desc', options.sortDescImage); + if(options.sortAvailable) { + addMenuItem($menu, columnDef, 'Sort Ascending', 'sort-asc', options.sortAscImage); + addMenuItem($menu, columnDef, 'Sort Descending', 'sort-desc', options.sortDescImage); + } var filterOptions = ""; @@ -269,4 +273,4 @@ "onCommand": new Slick.Event() }); } -})(jQuery); \ No newline at end of file +})(jQuery); From a41ae4c54c7ee4dd49067794ea65d66139054960 Mon Sep 17 00:00:00 2001 From: James Silberbauer Date: Mon, 24 Jun 2013 22:36:17 +0200 Subject: [PATCH 2/8] Add sortAvailable option to README. --- README.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/README.md b/README.md index 6e6ec07..fb4898a 100644 --- a/README.md +++ b/README.md @@ -10,6 +10,9 @@ This adds a filter to the column header, displaying an ordered list of the value The plugin relies on the grid data being sourced from a DataView as it handles the filtering. +Options: +* sortAvailable (default: true). Set to false to remove the ability to sort columns via the plugin. + Overlays (ext.overlays.js) -------- From a1e5d8d4c59ee2bd6b9283be991a5e8e3bfb819a Mon Sep 17 00:00:00 2001 From: James Silberbauer Date: Mon, 24 Jun 2013 22:41:32 +0200 Subject: [PATCH 3/8] Add ability to have unfiltered columns. --- README.md | 1 + ext.headerfilter.js | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index fb4898a..b492dcf 100644 --- a/README.md +++ b/README.md @@ -12,6 +12,7 @@ The plugin relies on the grid data being sourced from a DataView as it handles t Options: * sortAvailable (default: true). Set to false to remove the ability to sort columns via the plugin. +* Column option: unfiltered (If set to true, that column will not have a header filter available). Overlays (ext.overlays.js) -------- diff --git a/ext.headerfilter.js b/ext.headerfilter.js index 69ebecb..145e3bb 100644 --- a/ext.headerfilter.js +++ b/ext.headerfilter.js @@ -60,8 +60,9 @@ } function handleHeaderCellRendered(e, args) { - console.log('handleHeaderCellRendered'); + //console.log('handleHeaderCellRendered'); var column = args.column; + if(column.unfiltered) { return false; } var $el = $("
") .addClass("slick-header-menubutton") From c7cef520358e0f1a98451e672108f08f3ca0da3b Mon Sep 17 00:00:00 2001 From: James Silberbauer Date: Tue, 2 Jul 2013 10:48:30 +0200 Subject: [PATCH 4/8] Make label css more specific. --- plugins-common.css | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins-common.css b/plugins-common.css index d25c1aa..b665d5a 100644 --- a/plugins-common.css +++ b/plugins-common.css @@ -46,7 +46,7 @@ width: 200px; } -label +div .filter label { display: block; margin-bottom: 5px; From 5fb89c1cbf39bdf879031f6d919bc9e5839554e8 Mon Sep 17 00:00:00 2001 From: James Silberbauer Date: Tue, 2 Jul 2013 10:49:23 +0200 Subject: [PATCH 5/8] Multi-column sorting example. --- css/slick.grid.css | 4 +- examples/example-3-with-sort-and-search.htm | 218 ++++++++++++++++++++ ext.headerfilter.js | 5 +- 3 files changed, 224 insertions(+), 3 deletions(-) create mode 100644 examples/example-3-with-sort-and-search.htm diff --git a/css/slick.grid.css b/css/slick.grid.css index 6a416db..8b2f35f 100644 --- a/css/slick.grid.css +++ b/css/slick.grid.css @@ -53,11 +53,11 @@ classes should alter those! } .slick-sort-indicator-desc { - background: url(images/sort-desc.gif); + background: url(../images/sort-desc.png); } .slick-sort-indicator-asc { - background: url(images/sort-asc.gif); + background: url(../images/sort-asc.png); } .slick-resizable-handle { diff --git a/examples/example-3-with-sort-and-search.htm b/examples/example-3-with-sort-and-search.htm new file mode 100644 index 0000000..894914c --- /dev/null +++ b/examples/example-3-with-sort-and-search.htm @@ -0,0 +1,218 @@ + + + + + + + SlickGrid Filter and Overlay example + + + + + + +
+
    +
  • Demonstrates the Row and Header overlays, the Selected Cell overlay, filter, and Fill Down
  • +
  • The Title column is editable so has the fill down function enabled
  • +
  • Sorting from the filer menu is turned off. Columns can be sorted by clicking on the header. Multi-sort works by holding down shift when clicking on a second header
  • +
  • The search box allows for searching all columns within filtered rows
  • +
  • The Row column has filtering turned off
  • +
+
+
+
+
+ +
+ + + + + + + + + + + + + + + diff --git a/ext.headerfilter.js b/ext.headerfilter.js index 145e3bb..35df437 100644 --- a/ext.headerfilter.js +++ b/ext.headerfilter.js @@ -101,7 +101,6 @@ } function showFilter(e) { - e.stopPropagation(); var $menuButton = $(this); var columnDef = $menuButton.data("column"); @@ -175,6 +174,10 @@ $menu.css("top", offset.top + $(this).height()) .css("left", (left > 0 ? left : 0)); + // Stop propagation so that it doesn't register as a header click event. + // THIS CORRECTLY STOPS THE HEADER SORT, BUT THEN ALSO BLOCKS BEHAVIOUR OF THE CLEAR BUTTON... + // e.preventDefault(); + // e.stopPropagation(); } function columnsResized() { From 3baa8ace4a1fea1f041305032fabf38fd84dd837 Mon Sep 17 00:00:00 2001 From: James Silberbauer Date: Tue, 2 Jul 2013 11:58:49 +0200 Subject: [PATCH 6/8] Search within filtered rows. --- examples/example-3-with-sort-and-search.htm | 43 +++++++++++++++++++-- 1 file changed, 40 insertions(+), 3 deletions(-) diff --git a/examples/example-3-with-sort-and-search.htm b/examples/example-3-with-sort-and-search.htm index 894914c..5a355b0 100644 --- a/examples/example-3-with-sort-and-search.htm +++ b/examples/example-3-with-sort-and-search.htm @@ -42,7 +42,7 @@
  • Demonstrates the Row and Header overlays, the Selected Cell overlay, filter, and Fill Down
  • The Title column is editable so has the fill down function enabled
  • Sorting from the filer menu is turned off. Columns can be sorted by clicking on the header. Multi-sort works by holding down shift when clicking on a second header
  • -
  • The search box allows for searching all columns within filtered rows
  • +
  • The search box allows for searching all columns within filtered rows:
  • The Row column has filtering turned off
  • @@ -65,6 +65,7 @@