Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Selector: type -> selectorType, update CHANGES/README

  • Loading branch information...
commit 8852c0a14d67c78eb7d82b048581b2c1af55f7cd 1 parent 6c93cc5
@kfranqueiro kfranqueiro authored
Showing with 49 additions and 16 deletions.
  1. +12 −2 CHANGES.md
  2. +21 −5 README.md
  3. +11 −4 Selector.js
  4. +5 −5 test/Selector.html
View
14 CHANGES.md
@@ -50,7 +50,7 @@ Store-backed grids also now have an `updateDirty(id, field, value)` method,
which can be used to update dirty state of items represented in the grid.
(On master this was previously known as `setDirty`, but did not exist in v0.2.)
-## Selection / CellSelection / Selector
+## Selection / CellSelection
### dgrid-select and dgrid-deselect events
@@ -92,6 +92,16 @@ Previously, the `Selection` module would clear the selection whenever a list
or grid is refreshed. While this is still the default, the behavior can now
be disabled by setting `deselectOnRefresh` to `false`.
+## Selector
+
+### columndef.type is now columndef.selectorType
+
+In dgrid 0.2, the selector type (generally either `"checkbox"` or `"radio"`)
+could be specified within the column definition object via the `type` property.
+This has been changed to `selectorType` to avoid ambiguity. The selector type
+can also be specified as the second argument to the `Selector` column plugin
+function instead, as before.
+
## Editor
Editor has been significantly refactored since v0.2. The most notable changes
@@ -129,7 +139,7 @@ to perform the same lookup again on the other end.
Since it is possible to get cell and row information from this property,
the previously-exposed `rowId` property of the `dgrid-datachange` event is
-now deprecated and will be removed in the beta release.
+now deprecated and will be removed in a future release.
The `dgrid-datachange` event also now includes a `grid` property containing a
reference to the Grid instance from which the event was fired.
View
26 README.md
@@ -506,17 +506,33 @@ as well as the `GridFromHtml_Editors` test page for declarative examples.
## Tree
The Tree plugin enables expansion of rows to display children.
-It expects to operate on an OnDemandGrid, whose store is expected to provide
-a `getChildren(object, options)` method to return the children for each object.
-Note that for best results, `getChildren` should return results with an `observe`
-function as well, so that changes to children can also be reflected as they occur.
+It expects to operate on a store-backed grid such as an OnDemandGrid, whose
+store is expected to provide a `getChildren(object, options)` method to return
+the children for each object. Note that for best results, `getChildren` should
+return results with an `observe` function as well, so that changes to children
+can also be reflected as they occur.
The store may also (optionally) provide a `mayHaveChildren(object)` method
which returns a boolean indicating whether or not the row can be expanded.
## Selector
-TODOC
+Used in conjunction with the Selection mixin, the Selector plugin dedicates a
+column to the purpose of rendering a selector component, providing alternate
+means for selecting and deselecting rows in a grid.
+
+The Selector plugin supports the following additional column definition property:
+
+* `selectorType`: Specifies the type of selector component to use. Defaults to
+ `checkbox`, but `radio` may also be specified, as a more appropriate choice for
+ grids in `single` selection mode.
+
+Alternatively, the `selectorType` may be specified as the second argument to
+the Selector function instead of including it within the column definition.
+
+Note that a Selector column can be used to allow selection even in a grid where
+`selectionMode` is set to `none`, in which case the controls in the Selector
+column will be the only means by which a user may select or deselect rows.
### Recommendations for the editOn property
View
15 Selector.js
@@ -1,7 +1,13 @@
-define(["dojo/on", "dojo/aspect", "dojo/_base/sniff", "put-selector/put"], function(on, aspect, has, put){
+define(["dojo/_base/kernel", "dojo/on", "dojo/aspect", "dojo/_base/sniff", "put-selector/put"],
+function(kernel, on, aspect, has, put){
return function(column, type){
- // accept arguments as parameters to Selector function, or from column def
- column.type = type = type || column.type;
+
+ if(column.type){
+ column.selectorType = column.type;
+ kernel.deprecated("columndef.type", "use columndef.selectorType instead", "dgrid 1.0");
+ }
+ // accept type as argument to Selector function, or from column def
+ column.selectorType = type = type || column.selectorType || "checkbox";
column.sortable = false;
var grid, recentInput, recentTimeout, headerCheckbox;
@@ -100,7 +106,8 @@ define(["dojo/on", "dojo/aspect", "dojo/_base/sniff", "put-selector/put"], funct
var disabled = column.disabled;
var renderInput = typeof type == "function" ? type : function(value, cell, object){
var parent = cell.parentNode;
- put(parent && parent.contents ? parent : cell, ".dgrid-selector"); // must set the class name on the outer cell in IE for keystrokes to be intercepted
+ // must set the class name on the outer cell in IE for keystrokes to be intercepted
+ put(parent && parent.contents ? parent : cell, ".dgrid-selector");
var input = cell.input || (cell.input = put(cell, "input[type="+type + "]", {
tabIndex: isNaN(column.tabIndex) ? -1 : column.tabIndex,
disabled: disabled && (typeof disabled == "function" ? disabled(object) : disabled),
View
10 test/Selector.html
@@ -28,13 +28,13 @@
"dojo/_base/declare", "dojo/_base/array", "dojo/json", "dgrid/test/data/base", "dojo/domReady!"],
function(on, win, Grid, Selector, Selection, Keyboard, declare, arrayUtil, json, testStore){
var columns = { // you can declare columns as an object hash (key translates to field)
- col1: Selector({ type: "checkbox", disabled: function(object){ return object.col1 == "note"; }}),
+ col1: Selector({ disabled: function(object){ return object.col1 == "note"; }}),
id: "ID",
col2: {label: 'Column 2', sortable: false},
col3: {label: 'Column 3'}
};
- var columns2 = { // you can declare columns as an object hash (key translates to field)
- col1: Selector({ type: "checkbox", label:"Select"}),
+ var columns2 = {
+ col1: Selector({ label: "Select" }),
id: "ID",
col2: {label: 'Column 2', sortable: false},
col3: {label: 'Column 3'}
@@ -61,8 +61,8 @@
columns: columns2,
allowSelectAll: false
}, "grid2");
- var columnsRadio = { // you can declare columns as an object hash (key translates to field)
- col1: Selector({ label: 'Radio', type: "radio", disabled: function(object){ return object.col3 == "read"; } }),
+ var columnsRadio = {
+ col1: Selector({ label: 'Radio', disabled: function(object){ return object.col3 == "read"; } }, "radio"),
id: "ID",
col2: {label: 'Column 2', sortable: false},
col3: {label: 'Column 3'}
Please sign in to comment.
Something went wrong with that request. Please try again.