From 75ef00182ea80900e893d4c3e502994e954b4b40 Mon Sep 17 00:00:00 2001 From: Rufus Pollock Date: Sun, 14 Oct 2012 18:13:13 +0100 Subject: [PATCH] [#246,bugfix,slickgrid][s]: fix for issue where slickgrid view not presenting columns in order of Dataset Fields - fixes #246. Bug details: Issue was that sorting of columns was happening inside SlickGrid view even though not supposed to (no special column order had been provided). Specific issue is at following lines https://github.com/okfn/recline/blob/4737d7ecc53f9a4eb7e381ddebe63027781ae2b8/src/view.slickgrid.js#L88: // Order them if there is ordering info on the state if (this.state.get('columnsOrder')) { Problem is that state.columnsOrder is the empty array (by default) and in javascript `Boolean([])` is true. --- src/view.slickgrid.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/view.slickgrid.js b/src/view.slickgrid.js index f960d36c..75c56b76 100644 --- a/src/view.slickgrid.js +++ b/src/view.slickgrid.js @@ -85,7 +85,7 @@ my.SlickGrid = Backbone.View.extend({ }); // Order them if there is ordering info on the state - if (this.state.get('columnsOrder')){ + if (this.state.get('columnsOrder') && this.state.get('columnsOrder').length > 0) { visibleColumns = visibleColumns.sort(function(a,b){ return _.indexOf(self.state.get('columnsOrder'),a.id) > _.indexOf(self.state.get('columnsOrder'),b.id) ? 1 : -1; });