Created
June 16, 2009 18:27
-
-
Save chrishyle/130812 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
filterSelect: SC.SelectFieldView.design({ | |
layout: {left: 20, width: 150, top: 5, height: 20}, | |
objects: MyApp.user.computedList(), | |
nameKey: "name", | |
valueKey: "guid", //changed to "value" for array | |
sortKey: "name" | |
}), |
This file contains hidden or 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
// doesn't work: | |
computedList: function(){ | |
return this.get('memberships').getEach('userGroup').filterProperty('type', "myType"); | |
// array of SC.Objects | |
// calling .toArray() has no effect on the result | |
} | |
//works: | |
computedArray: function(){ | |
var groups = this.get('memberships').getEach('userGroup').filterProperty('type', "myType"); | |
var groupsArray = new Array(); | |
for(var i=0; i < groups.length; i++){ | |
var groupsFmt = { | |
name: groups.objectAt(i).get('name'), | |
value: groups.objectAt(i).get('guid') | |
}; | |
groupsArray.push(groupsFmt); | |
} | |
return groupsArray; | |
//looks like: { name: 'MyName', value: 'MyValue' } | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment