sproutcore/sproutcore — pull request #758 by workmanw (2012-03-24 02:22:08+00:00)
Title: Added bindings between the tree controller and it's tree item observer to keep the selection options in sync

The options referred to in the title are 'allowsSelection', 'allowsMultipleSelection' and 'allowsEmptySelection'.

This was prompted by #421, but we've run into this in our app as well. The problem here is that the SC.ListView expects to be able to get these properties from it's content object bound to the view ( 'content.allowsMultipleSelection' ). When a view is bound to an SC.ArrayController this works fine because the arrangedObjects property points to the controller it's self. But when bound to an SC.TreeController arrangedObjects points to the tree item observer, not the tree controller. So these properties are not properly retrieved by the view, because they do not reside on the content object.

My initial thought was to try mixing SC.SelectionSet into the tree item observer, however that makes it hard for the user to properly set the options. Additionally, the tree controller should have SC.SelectionSet mixed in because that's where selection needs to reside.

So that brings me to my solution. These options need to persist via binds between the tree controller and the tree item observer. As always, I'd welcome any alternative solutions.