Since I know this can’t be done since this object doesn’t allow for it, I’d like to fake this functionality in Skuid. I can create a text field called Role. I can create a custom field renderer. I can store the Role ID in the text field and render it’s Name in read mode and render a picklist in edit mode.
The question is how as I’m still rather novice when it comes to custom field renderers.
Page 1 / 1
I’ve gotten this far, but some pointers would be appreciated. Please don’t give me the solution though. Going to the “else” bit now as I know how to do this part.
var field = argumentsr0], value = skuid.utils.decodeHTML(argumentsr1]), userRoleModel = skuid.$M('UserRoles'); if (field.mode == 'edit') { // lookup values in userRole in order to display then in a picklist } else { // find the Name of the userRole based on the value in the text field called Role and display name }
Halfway there.
var field = argumentsn0], value = skuid.utils.decodeHTML(argumentsn1]), $ = skuid.$, dfd = new jQuery.Deferred(), userRoleModel = skuid.$M('UserRoles'), currentUserRoleModel = skuid.$M('CurrentUserRole'), currentUserRoleModelCond = currentUserRoleModel.getConditionByName('roleId'); if (field.mode == 'edit') { // lookup values in userRole in order to display then in a picklist } else { // find the Name of the userRole based on the value in the text field called Role and display name currentUserRoleModel.setCondition(currentUserRoleModelCond,value); $.when(currentUserRoleModel.updateData()) .done(function(){ var currentURMRow = currentUserRoleModel.getFirstRow(); // set the value of the field skuid.ui.fieldRenderers.TEXT.read( field, currentURMRow.Name ); dfd.resolve(); }) .fail(function(){ dfd.reject(); }); } return dfd.promise();
I think I got it.
- Create an array called userRolePicklist
- Loop through the rows in the userRole model
- Create an object for each row and push it into the array userRolePicklist
- update field.metadata.picklistEntries with userRolePicklist
AWESOME!!! A text field that acts like a lookup field to an object that doesn’t allow lookups to it!!!
Pat…this thread makes me smile. Four posts of you answering your own question.
hehehehe… I wasn’t willing to wait for the answer.
Talking about arrays and objects like a real pro, no more javascript rookie!
Getting there. Slow but sure.
Well done Pat…
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.