2011-03-30 176 views
0

我想了解它是如何工作的。我的看法:需要一些幫助SC.SelectView

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 

         }) 

我找不到有關選擇查看的任何其他信息。我如何預先選擇項目,選擇何處,每當我做出選擇時,爲什麼會出現錯誤?

回答

0

選擇: 可以說,你有這樣的:

MyApp.roleController = SC.ObjectController({ 
    selectedRoleId: 1; 
}) 

然後在您的視圖:

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' 

         }) 

您的選擇將被綁定到的 'selectedRoleId' 的roleController