mleibman/SlickGrid — pull request #221 by yipdw (2011-10-14 23:46:42+00:00)
Title: Support #get(attribute) for accessing values on model objects.

Motivation:

Backbone provides model
objects and collections. It is possible to pass a Backbone collection
to a SlickGrid instance by implementing getLength and getItem on the
Backbone collection like so:

var WidgetsCollection = Backbone.Collection.extend({
model: Widget,

getLength: function () {
return this.length;
},

getItem: function (i) {
return this.at(i);
}
}),
widgets = new WidgetsCollection(),
grid = new Slick.Grid($('#grid'), widgets, ...)

However, Backbone models provide field access via a `get` method, not `[]`.

---

As far as I am aware, no version of JavaScript permits either the meaning of []
to be changed on a per-object basis or a redefinition of the object property
lookup code. Hence the change in this commit, which modifies field access to
behave similarly to getDataLength and getDataItem.

`get` is, in my experience, a common name for a method that retrieves the value
of a field on a model object: Backbone.Model, SproutCore's SC.Observable, and
Sencha's (i.e. ExtJS 4.0) Ext.data.Model all implement `get` with similar
semantics.