Thursday, 10 March 2011

SproutCore: SC.Drag + SC.ArrayController != 'PIE' || 'CAKE'

I nearly use Thermonuclear option.


You would think it easy.  You would be wrong.

Oh so very wrong.  Why you ask?  Well, the first oblong wheel is the data in SC.ArrayController.  Da, it simple right:
var users = MyApp.store.find('MyApp.User'));
 MyApp.usersController.set('content', users);
 Da, easy.  Find all users.  Show into SC.ArrayController.  Go eat borscht.  Drink Vodka.
 Come back to work and make two SC.ListView

....
allUsers: SC.SourceListView.design({
... some stupid layout
contentBinding: 'MyApp.usersController.arrangedObjects'
canEditContent: YES,
canReorderContent: YES,
delegate: MyApp.mustMakeDelegate
}),
 usersILike: SC.SourceListView.desig({
...
delegate: MyApp.mustMakeDelegate,
isDropTarget: YES // what else?
})
 Whooo wheee now I reload page and drag and drop contents right?  Sookin Syn!
Dirty mother: SC.Error:sc599:SC.RecordArray is not editable (-1)!!!!!!!

Problem: store hate me.  Solution:  hide from store by wrapping in blanket initial find like dis:

var users = SC.A(MyApp.store.find('MyApp.User')));
 MyApp.usersController.set('content', users);
Alexei say SC.A is not short for 'SproutCore.Assholes: have a good time figureing this out', but I'm not sure.

Da, I know it should all be on one line, without transient variable initializations, but Alexei say split it for search engine optimization.

If you know better approach let me know.

No comments:

Post a Comment