From 7b2d97029800f7f1dda862e2ba4c3f8d23a8ad09 Mon Sep 17 00:00:00 2001 From: "Kenneth G. Franqueiro" Date: Thu, 21 Jun 2012 17:21:43 -0400 Subject: [PATCH] Fix #199: ColumnHider: don't ignore hidden if unhidable is set --- extensions/ColumnHider.js | 11 +++++++---- test/extensions/ColumnHider.html | 7 ++++--- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/extensions/ColumnHider.js b/extensions/ColumnHider.js index 576701fa8..746047568 100644 --- a/extensions/ColumnHider.js +++ b/extensions/ColumnHider.js @@ -99,6 +99,12 @@ define(["dojo/_base/declare", "dojo/has", "dojo/on", "dojo/query", "dojo/dom", " for(j = 0, len = this.subRows[i].length; j < len; j++){ col = this.subRows[i][j]; id = col.id; + + if(col.hidden){ + // hidden state is true; hide the column + this._columnStyleRules[id] = this.styleColumn(id, "display: none"); + } + // allow cols to opt out of the hider (specifically for selector col) if (col.unhidable) continue; @@ -112,10 +118,7 @@ define(["dojo/_base/declare", "dojo/has", "dojo/on", "dojo/query", "dojo/dom", " '" for="' + checkId + '">' + col.label.replace(/'; - if(col.hidden){ - // hidden state is true; hide the column - this._columnStyleRules[id] = this.styleColumn(id, "display: none"); - }else{ + if(!col.hidden){ // hidden state is false; checkbox should be initially checked div.firstChild.checked = true; } diff --git a/test/extensions/ColumnHider.html b/test/extensions/ColumnHider.html index 7d9289b53..da15daf0f 100644 --- a/test/extensions/ColumnHider.html +++ b/test/extensions/ColumnHider.html @@ -39,7 +39,7 @@ function(lang, Grid, ColumnHider, ColumnResizer, Selection, declare, testStore){ var columns = { col1: "Column 1Column1Column 1 Column 1", - col2: {label: "Column2 (unhidable)", sortable: false, unhidable: true}, + col2: { label: "Column2 (unhidable)", sortable: false, unhidable: true }, col3: "Column3333333333333333333", col4: "Column 4", col5: "Column 5" @@ -47,7 +47,8 @@ columns1 = lang.clone(columns); columns2 = [ { field: "col2", label: "Col2" }, - { field: "col4", label: "Col4", sortable: false }, + // test setting unhidable *and* hidden (i.e. not in menu, not displayed) + { field: "col4", label: "Col4", sortable: false, hidden: true, unhidable: true }, { field: "col1", label: "Col1" }, { field: "col5", label: "Column 5" } ]; @@ -74,7 +75,7 @@

A basic grid with the column hider plugin

Buttons to test changing column structure: - +

Another grid w/ ColumnHider and ColumnResizer