SitePen/dgrid — pull request #49 by SitePenKenFranqueiro (2011-10-26 16:35:21+00:00)
Title: Column share

These changes attempt to make it safe to reuse column definition objects across multiple Grid instances.

First and foremost, mixin is always performed (using a slightly simplified function, avoiding pulling `dojo/_base/lang` into Grid) on column objects within `_configColumn`.

However, since column plugins are passed the original column definition object (before the mixin occurs), and may reference the `id` and `field` properties, these are still pushed back into the original column def object as well. This should be harmless, since these properties would be normalized the same way on every call to `_configColumn` anyway.

The bigger issue is with the `grid` property, which is pushed onto each column definition object after the mixin occurs, but this reference to the "owning" grid is needed by column plugins like Editor and Tree in order to listen for / emit events and call APIs on the Grid itself. This changeset replaces that property with an additional argument passed to the `renderHeaderCell` and `renderCell` functions.

I will fully admit I am not terribly fond of some of the changes this required in order to work (though I do think `_configColumn` itself benefited from some straightening-out). At the same time, I'm not particularly fond of the idea of forcing people to clone their columns objects, being unable to simply reuse the same structure across multiple Grid instances. I'm submitting this pull request to solicit others' feedback and ideas.