Skip to content

Commit

Permalink
Fix SitePen#664: Allow blank labels (specified as empty string)
Browse files Browse the repository at this point in the history
  • Loading branch information
Kenneth G. Franqueiro committed Jul 19, 2013
1 parent 72cd90a commit 51d5f4f
Show file tree
Hide file tree
Showing 7 changed files with 13 additions and 9 deletions.
2 changes: 2 additions & 0 deletions CHANGES.md
Expand Up @@ -13,6 +13,8 @@ This document outlines changes since 0.3.0. For older changelogs, see the
after scrolling. (#548)
* Added the capability to opt out of custom TouchScroll logic on devices that
support touch, by setting `useTouchScroll: false` on the instance. (#656)
* Fixed logic in `Grid`, `GridFromHtml`, and `selector` to allow specifying a
blank label for a column by passing an empty string to `column.label`. (#664)

### Mixins

Expand Down
5 changes: 3 additions & 2 deletions Grid.js
Expand Up @@ -196,8 +196,9 @@ function(kernel, declare, listen, has, put, List, miscUtil){
// allow for custom header content manipulation
if(column.renderHeaderCell){
appendIfNode(contentNode, column.renderHeaderCell(contentNode));
}else if(column.label || column.field){
contentNode.appendChild(document.createTextNode(column.label || column.field));
}else if("label" in column || column.field){
contentNode.appendChild(document.createTextNode(
"label" in column ? column.label : column.field));
}
if(column.sortable !== false && field && field != "_item"){
th.sortable = true;
Expand Down
2 changes: 1 addition & 1 deletion GridFromHtml.js
Expand Up @@ -114,7 +114,7 @@ function(Grid, declare, put){
obj = GridFromHtml.utils.getPropsFromNode(th);

// inspect standard attributes, but data attribute takes precedence
obj.label = obj.label || th.innerHTML;
obj.label = "label" in obj ? obj.label : th.innerHTML;
obj.field = obj.field || th.className || th.innerHTML;
if(!obj.className && th.className){ obj.className = th.className; }
if(!obj.rowSpan && (tmp = getNum(th, "rowspan"))){ obj.rowSpan = tmp; }
Expand Down
3 changes: 2 additions & 1 deletion selector.js
Expand Up @@ -182,7 +182,8 @@ function(kernel, arrayUtil, on, aspect, has, put){
renderInput(value, cell, object);
};
column.renderHeaderCell = function(th){
var label = column.label || column.field || "";
var label = "label" in column ? column.label :
column.field || "";

if(type == "radio" || !grid.allowSelectAll){
th.appendChild(document.createTextNode(label));
Expand Down
4 changes: 2 additions & 2 deletions test/GridFromHtml.html
Expand Up @@ -112,13 +112,13 @@ <h2>1a: GridFromHtml with single column with formatter for _item field</h2>
</tr>
</thead>
</table>
<h2>1b: GridFromHtml with single column with get for order field</h2>
<h2>1b: GridFromHtml with single column with get for order field, and blank label for 3rd column</h2>
<table id="gridFromHtmlLegacyGet">
<tbody>
<tr>
<th data-dgrid-column="{field:'order', get:testGet}">Step</th>
<th>name</th>
<th data-dgrid-column="{field:'description', sortable:false}">what to do</th>
<th data-dgrid-column="{label:'', field:'description', sortable:false}">what to do</th>
</tr>
</tbody>
</table>
Expand Down
2 changes: 1 addition & 1 deletion test/Grid_rendering.html
Expand Up @@ -103,7 +103,7 @@
renderCell: testRenderCell
},
name: {},
description: {label: "what to do", sortable: false}
description: {label: "", sortable: false} // Test blank label
};
require(["dgrid/Grid", "dgrid/OnDemandGrid", "dojo/store/Memory", "dojo/store/Observable", "dojo/_base/declare", "dojo/_base/lang", "dojo/parser", "dojo/query", "dgrid/test/data/base", "dojo/domReady!"],
function(Grid, OnDemandGrid, Memory, Observable, declare, lang, parser, query){
Expand Down
4 changes: 2 additions & 2 deletions test/selector.html
Expand Up @@ -73,7 +73,7 @@
store: testStore,
selectionMode: "none",
columns: {
col1: selector({ label: "Select" }),
col1: selector({ label: "" }), // Test blank label
id: "ID",
col2: {label: 'Column 2', sortable: false},
col3: {label: 'Column 3'}
Expand Down Expand Up @@ -149,7 +149,7 @@ <h2>A grid with radio selectors</h2>
Set selection mode to "single" (to test sync)</button>
</div>
<div id="grid-radio"></div>
<h2>A grid with checkbox selectors, with select-all disabled</h2>
<h2>A grid with checkbox selectors, with select-all disabled, blank label in selector column</h2>
<div id="grid2"></div>
<h2>A grid, initially without a selector column</h2>
<div id="gridNoSelector"></div>
Expand Down

0 comments on commit 51d5f4f

Please sign in to comment.