diff --git a/Grid.js b/Grid.js index 1db8c110f..0e31b3a27 100644 --- a/Grid.js +++ b/Grid.js @@ -144,6 +144,7 @@ function(kernel, declare, listen, has, put, List, miscUtil){ }, renderRow: function(object, options){ + var self = this; var row = this.createRowCells("td", function(td, column){ var data = object; // we support the field, get, and formatter properties like the DataGrid @@ -152,8 +153,15 @@ function(kernel, declare, listen, has, put, List, miscUtil){ }else if("field" in column && column.field != "_item"){ data = data[column.field]; } - if(column.formatter){ - td.innerHTML = column.formatter(data); + var formatter = column.formatter; + if(formatter){ + //we support formatterScope like the DataGrid + var scope = self.formatterScope; + if(scope && typeof formatter == "string"){ + formatter = scope[formatter]; + } + + td.innerHTML = formatter(data, object); }else if(column.renderCell){ // A column can provide a renderCell method to do its own DOM manipulation, // event handling, etc. diff --git a/List.js b/List.js index a7807ea50..7a1981d5b 100644 --- a/List.js +++ b/List.js @@ -740,12 +740,12 @@ function(kernel, declare, listen, has, miscUtil, TouchScroll, hasClass, put){ // Sets named properties on a List object. // A programmatic setter may be defined in subclasses. // - // set() may also be called with a hash of name/value pairs, ex: + // set() may also be called with a hash of name/value pairs, ex: // | myObj.set({ // | foo: "Howdy", // | bar: 3 // | }) - // This is equivalent to calling set(foo, "Howdy") and set(bar, 3) + // This is equivalent to calling set(foo, "Howdy") and set(bar, 3) if(typeof name === "object"){ for(var k in name){ diff --git a/Selection.js b/Selection.js index 41cccb621..0532511a6 100644 --- a/Selection.js +++ b/Selection.js @@ -106,7 +106,7 @@ return declare(null, { // If true, the selection object will be cleared when refresh is called. deselectOnRefresh: true, - //allowSelectAll: Boolean + // allowSelectAll: Boolean // If true, allow ctrl/cmd+A to select all rows. // Also consulted by the selector plugin for showing select-all checkbox. allowSelectAll: false, diff --git a/extensions/DnD.js b/extensions/DnD.js index 49c39a75e..b45de5d0a 100644 --- a/extensions/DnD.js +++ b/extensions/DnD.js @@ -15,14 +15,14 @@ define([ "dojo/has!touch?./_DnD-touch-autoscroll", "xstyle/css!dojo/resources/dnd.css" ], function(declare, lang, arrayUtil, Deferred, aspect, on, topic, has, DnDSource, DnDManager, NodeList, put, touchUtil){ - // Requirements: + // Requirements // * requires a store (sounds obvious, but not all Lists/Grids have stores...) // * must support options.before in put calls // (if undefined, put at end) // * should support copy // (copy should also support options.before as above) - // TODOs: + // TODOs // * consider sending items rather than nodes to onDropExternal/Internal // * consider emitting store errors via OnDemandList._trackError diff --git a/test/formatters.html b/test/formatters.html new file mode 100644 index 000000000..cf48bad4b --- /dev/null +++ b/test/formatters.html @@ -0,0 +1,85 @@ + + + + + Test formatters and formatterScope + + + + + + +

A basic grid with height:auto

+
+ dgrid + +