Skip to content

Commit

Permalink
Doc fixes
Browse files Browse the repository at this point in the history
* Document 2nd formatter argument (fixes #1099)
* Fix syntax errors in 0.4 Migration Guide

Thanks @schallm for pointing out the missing formatter docs, and
@gavinr for pointing out one of the Migration Guide syntax errors.
  • Loading branch information
kfranqueiro committed Mar 23, 2015
1 parent 4b87756 commit 623066e
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion doc/components/core-components/Grid.md
Expand Up @@ -185,6 +185,6 @@ Property | Description
`sortable` | Indicates whether or not the grid should allow sorting by values in this field, by clicking on the column's header cell. Defaults to `true`. Note that it is always possible to programmatically sort a Grid by a given field by calling `set("sort", property, descending)` regardless of`sortable` status or even visible presence in the Grid altogether.
`get(item)` | An optional function that, given a data item, will return the value to render in the cell.
`set(item)` | An optional function that, given a modified data item, will return the value to set for the respective field on that item upon a call to `save()`. If no value is returned, the value as set in the passed item will be used. (Modifying the passed item directly is thus also an option.)
`formatter(value)` | An optional function that, given the value to be displayed, will return a string of HTML for rendering. If `formatterScope` is used, this can be a string instead of a function, in which case a function will be looked up on the `formatterScope` object using the given string. (Note: if a custom `renderCell` is specified, `formatter` will be ignored unless the custom `renderCell` accounts for it.)
`formatter(value, object)` | An optional function that will return a string of HTML for rendering. The function is passed the value that would normally be rendered, and the object from the collection. If `formatterScope` is used, this can be a string instead of a function, in which case a function will be looked up on the `formatterScope` object using the given string. (Note: if a custom `renderCell` is specified, `formatter` will be ignored unless the custom `renderCell` accounts for it.)
`renderCell(object, value, node, options)` | An optional function that will be called to render the value into the target cell. `object` refers to the record from the grid's collection for the row, and `value` refers to the specific value for the current cell (which may have been modified by the column definition's `get` function). `node` refers to the table cell that will be placed in the grid if nothing is returned by `renderCell`; if `renderCell` returns a node, that returned node will be placed inside the table cell. (Note: if a custom `renderCell` is specified, `formatter` will be ignored unless the custom `renderCell` accounts for it.)
`renderHeaderCell(node)` | An optional function that will be called to render the column's header cell. Like `renderCell`, this may either operate on the node directly, or return a new node to be placed within it.
18 changes: 9 additions & 9 deletions doc/migrating/0.4-Migration.md
Expand Up @@ -121,15 +121,15 @@ example of displaying items in a grid based on the items' sizes when buttons are
```js
on(smallButtonNode, 'click', function () {
// When the "small" button is clicked, display only the small items.
grid.set('collection', store.filter({ size: 'small' });
grid.set('collection', store.filter({ size: 'small' }));
});
on(mediumButtonNode, 'click', function () {
// When the "medium" button is clicked, display only the medium items.
grid.set('collection', store.filter({ size: 'medium' });
grid.set('collection', store.filter({ size: 'medium' }));
});
on(largeButtonNode, 'click', function () {
// When the "large" button is clicked, display only the large items.
grid.set('collection', store.filter({ size: 'large' });
grid.set('collection', store.filter({ size: 'large' }));
});
```

Expand Down Expand Up @@ -157,7 +157,7 @@ either via the column definition object or via extra arguments:
```js
require([
'dgrid/Grid', 'dgrid/editor'
]), function (Grid, editor) {
], function (Grid, editor) {
var grid = new Grid({
columns: [
// Passing all editor properties in the column definition parameter:
Expand All @@ -184,7 +184,7 @@ require([
})
]
}, 'grid');
}
});
```

#### dgrid 0.4
Expand All @@ -195,7 +195,7 @@ property (and optionally others) on each editable column:
```js
require([
'dojo/_base/declare', 'dgrid/Grid', 'dgrid/Editor'
]), function (declare, Grid, Editor) {
], function (declare, Grid, Editor) {
// Create a custom grid by mixing in Editor
var grid = new (declare([ Grid, Editor ]))({
columns: [
Expand Down Expand Up @@ -226,7 +226,7 @@ require([
}
]
}, 'grid');
}
});
```
Refer to the [`Editor` mixin documentation](../components/mixins/Editor.md)
Expand Down Expand Up @@ -488,8 +488,8 @@ greatly simplifying the implementation. Logic pertaining to query results is no
If you want a list or grid that will display all of the items in a store without paging and without the full
implementation of `OnDemandList`, take a look at the
[Rendering All Store Data at Once](http://dgrid.io/tutorials/0.4/single_query/) tutorial.
It demonstrates how to extend 'dgrid/_StoreMixin' to create a lightweight mixin that fetches all items from a collection
when a list or grid is refreshed.
It demonstrates how to extend `dgrid/_StoreMixin` to create a lightweight mixin that fetches all items from a
collection when a list or grid is refreshed.
Another benefit of `renderArray` *only* handling arrays, synchronously, is that it greatly simplifies extensions.
Previously, properly extending `renderArray` would involve using `dojo/when` to wrap its return
Expand Down

0 comments on commit 623066e

Please sign in to comment.