Picker content - object instead of string

In all the examples I've seen with Enyo UI data entry widgets, we always bind a string to "content:"

What if the item we have is something more complex? - perhaps JSON with a PK for a value in a DB along with a displayString (and maybe other information too).

I wish there was an "item:" and then a "displayString:" binding where reasonable values might be -> {item: this.getUser(), displayString: this.getUser().userName}

Right now what I'm doing is like this: {content: this.getUser().userName, published: {pk: this.getUser().pk, userName: this.getUser().username}}

I then have heroics of picking out the PK later on when responding to onChange events. Is there a better way to handle this?

Compare the typical onyx Picker example:

Note how content is just a string. Real world isn't like that. Typically information comes from a REST service and textual values can change. Imagine it was a "T-shirt size" field and "Medium" becomes "Med." suddenly... PK will always be the same but the displayString will be different. Is there a hidden API for Enyo that I'm not aware of?

I liked the grandaddy WebObjects way of doing things where there was an "item" and a "displayString" binding so that the full "object" is always bound to the "selection":

Please tell me I'm working too hard because Enyo already has a good way to do this that just isn't represented in the examples. Thanks!


Sign In or Register to comment.