-
-
Save zackdouglas/1565378 to your computer and use it in GitHub Desktop.
A working example of a two-teired ListView in Sproutcore 1.x (Tested in 1.6.x)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Test = SC.Application.create({ NAMESPACE: 'Test', VERSION: '0.1.0', store: SC.Store.create().from(SC.Record.fixtures) }) ; | |
Test.Top = SC.Record.extend({ | |
middles: SC.Record.toMany( | |
SC.Record.extend({ | |
bottoms: SC.Record.toMany( | |
SC.Record, | |
{ | |
isNested: YES, | |
isMaster: NO | |
} | |
) | |
}), | |
{ | |
isNested: YES, | |
isMaster: NO | |
} | |
) | |
}); | |
Test.TopObjectController = SC.ObjectController.create(); | |
Test.MiddlesArrayController = SC.ArrayController.create({ | |
isEditable: YES, | |
contentBinding: 'Test.TopObjectController.middles' | |
}); | |
top = Test.Top.create({ middles: [] }); | |
Test.TopObjectController.set('content', top); | |
newMiddle = SC.copy({ bottoms: [] }); | |
Test.MiddlesArrayController.addObject( newMiddle ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Test.TopView = SC.View.design({ | |
childViews: ['middles'], | |
middles: SC.ListView.design({ | |
contentBinding: 'Test.MiddlesArrayController.arrangedObjects', | |
exampleView: SC.View.design({ | |
render: function () { | |
sc_super(); | |
this.set('controller', | |
SC.ArrayController.create({ | |
content: this.getPath('content.bottoms') | |
}) | |
); | |
}, | |
childViews: ['bottoms'], | |
bottoms: SC.ListView.design({ | |
contentBinding: '.parentView.controller', | |
exampleView: SC.TextFieldView.design({ | |
contentBinding: '.content.myField' | |
}) | |
}) | |
}) | |
}) | |
}) |
sevifives
commented
Jan 11, 2012
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment