Created
October 1, 2013 15:40
-
-
Save zachelrath/6780455 to your computer and use it in GitHub Desktop.
Skuid custom field renderer to make any Field into a Multi-select Picklist
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
// | |
// SETTINGS | |
// | |
var POSSIBLE_PICKLIST_VALUES = [ | |
'Education', | |
'College Counseling', | |
'Job Club', | |
'Full Medical & Dental Care', | |
'Mental Health', | |
'FLSE', | |
'Lifetime Individual Sports', | |
'Self Expression', | |
'Community Organizer Comments', | |
'Community Organizer Outreach', | |
'Program Coordinator Comments' | |
]; | |
// Use to show as a Multiselect Picklist | |
var RENDERER = 'MULTIPICKLIST'; | |
// Use to show as a Picklist | |
// var RENDERER = 'PICKLIST'; | |
// | |
// OPERATIONAL CODE -- do not modify | |
// | |
var field = arguments[0], | |
value = skuid.utils.decodeHTML(arguments[1]), | |
$ = skuid.$, | |
frs = skuid.ui.fieldRenderers, | |
dt = field.metadata.displaytype; | |
// Run the Multipicklist editor on this field, | |
// using a comma as the delimiter | |
var entries = field.metadata.picklistEntries = []; | |
$.each(POSSIBLE_PICKLIST_VALUES,function(i,p){ | |
entries.push({ value: p, label: p, active: true, defaultValue: i==0}); | |
}); | |
if (field.mode == 'edit') { | |
frs[RENDERER].edit(field,value,','); | |
} else { | |
frs[dt][field.mode](field,value); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment