lsmith/yui3 — Issue #7: Add column sorting
Author: lsmith
Created: 2011-12-13 08:49:37+00:00
State: open

Class extension that auto-mix()es onto `Y.DataTable`

Should provide a method `sort(keyOrColIndex, descending?)` or `sort(keyOrIndex[, keyOrIndex]*)` on the DataTable proto.
Should provide a `sortable` attribute that accepts:

* 'auto' (default) - reads `columns` config for columns defined with `sortable: true`
* true - all columns are sortable
* false - none are sortable
* array of keys/indexes - specified columns are sortable

Since sorting can be considered a UI-specific operation[1], the implementation might leverage ModelList's sorting capability, but do so by assigning the `data` Models to an alternate ML implementation that had the sorting in place for the `bodyView` instance. The view ML should be synced to the DT ML via events, but there should be almost no memory overhead, since no new Models would be created, although there would be some risk that the DT's ML included an additional API that a custom `bodyView` expected to be in place.

An additional challenge is how a DT class extension would apply the sort arrow UI to the header cells. One idea would be to do this with a Plugin which was applied to the `headerView` instance. Since header rendering is not a performance vector, another option would be to have the class extension apply an `after('render')` to add the sort arrows. On the face of it, I prefer the Plugin idea, because there's room to configure the specific sort plugin with an additional DT attribute, contributed by teh class extension.

[1] Technically speaking, order is state, but a UI sort doesn't necessarily represent a data state change.