Need some help with SC.SelectView
I'm trying to understand how it works. I have view:
roleSwitch: SC.SelectView.design({
layout: {top:38, height: 20, width: 256 },
items: [{ title: 'a', isEnabled: YES, checkbox: NO },
开发者_如何学编程 { title: 'b', isEnabled: YES, checkbox: NO }],
itemTitleKey: 'title',
themeName: 'role',
showCheckbox: NO
})
I can't find any other information about SelectView. How i can pre-select item, where selection goes, why do I get an error each time when i make a selection?
Selection: Lets say you have this:
MyApp.roleController = SC.ObjectController({
selectedRoleId: 1;
})
Then in your view:
roleSwitch: SC.SelectView.design({
layout: {top:38, height: 20, width: 256 },
items: [{ title: 'a', isEnabled: YES, checkbox: NO, roleId: 1 },
{ title: 'b', isEnabled: YES, checkbox: NO, roleId: 2 }],
itemTitleKey: 'title',
themeName: 'role',
showCheckbox: NO,
itemValueKey: 'roleId',
valueBinding: 'MyApp.roleController.selectedRoleId'
})
Your selection will be bound to the 'selectedRoleId' of the roleController
精彩评论