Skip to content

Commit

Permalink
Fix #199: ColumnHider: don't ignore hidden if unhidable is set
Browse files Browse the repository at this point in the history
  • Loading branch information
Kenneth G. Franqueiro committed Jun 21, 2012
1 parent de74e14 commit 7b2d970
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
11 changes: 7 additions & 4 deletions extensions/ColumnHider.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -112,10 +118,7 @@ define(["dojo/_base/declare", "dojo/has", "dojo/on", "dojo/query", "dojo/dom", "
'" for="' + checkId + '">' + col.label.replace(/</g, "&lt;") +
'</label>';

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;
}
Expand Down
7 changes: 4 additions & 3 deletions test/extensions/ColumnHider.html
Original file line number Diff line number Diff line change
Expand Up @@ -39,15 +39,16 @@
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"
};
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" }
];
Expand All @@ -74,7 +75,7 @@ <h2>A basic grid with the column hider plugin</h2>
<div id="grid"></div>
<div>Buttons to test changing column structure:
<button onclick="grid.set('columns', columns2);">New Structure</button>
<button onclick="grid.set('columns', columns1);">Original</button>
<button onclick="grid.set('columns', columns1);">Original Structure</button>
</div>
<h2>Another grid w/ ColumnHider and ColumnResizer</h2>
<div id="gridresize"></div>
Expand Down

0 comments on commit 7b2d970

Please sign in to comment.