Skip to content

Instantly share code, notes, and snippets.

@chrishyle
Created June 16, 2009 18:27
Show Gist options
  • Save chrishyle/130812 to your computer and use it in GitHub Desktop.
Save chrishyle/130812 to your computer and use it in GitHub Desktop.
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"
}),
// 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