Welcome to the SRP Forum! Please refer to the SRP Forum FAQ post if you have any questions regarding how the forum works.
Can you associate data with a row in a combo box?
Hi,
I am wondering if the OI combo box has a feature which allows you to associate a piece of data with a row in the combo box?
Of course, I could create my own property that maps them, but I was wondering if there was a built in OI thing for this.
I am wondering if the OI combo box has a feature which allows you to associate a piece of data with a row in the combo box?
Of course, I could create my own property that maps them, but I was wondering if there was a built in OI thing for this.
Comments
No I am not talking about the database. I am talking about associating the output representation of a piece of data with its input representation.
The radio button in OI has this feature. I was hoping the combo box had it to, but it doesn't look like it does.
Oh well, I will have to do it myself, which of course is trivial, but it does make the code harder to understand, and it's already complicated enough.
It can take a little to get your head around it and it's a bit of code to set it up but if you make the effort and do so thinking generically you'll probably find yourself using it extensively
How did you get that combo box to look like that? I would like to create a combo box whose drop down contains images. Is that subclassing?
Edit: I can see how you made that. You're using the SRP combo box.
Wow...you give up easily don't you! :)
Of course we are fans of the SRP Combo feature (which is a property of the SRP Subclass control...hence where "subclass" comes from). It's a great way to give the user more information to search against while storing the critical data in the control/database.
However, if your requirements are to display one value yet store a different value in the database (which is what your radio button analogy suggests), then I recommend implementing a User-Defined Conversion (UDC). We do this regularly for systems where the database stores a simple code (e.g., like a letter) but the user sees a descriptive label instead.
I'd never thought to use a UDC in that manner. I mean I've done what you're referring to but via a hidden control rather than a UDC. I shall keep that in mind moving forward.
As for Josh's question, I think, after rereading a couple of times that what he is wanting to do is have a dropdown that allows the user to select an image or colour or image that represents a colour similar to the colour selection in the font properties that he mentioned in his other recent post.
Eg, user selects an item and then separately selects the colour of the item they want. Something that's common with online shopping but not so much in typical OI based desktop apps.
The radio button in OI has this feature. I was hoping the combo box had it to, but it doesn't look like it does.
That seems like a clear need for a custom Iconv/Oconv solution.
With regard to the implementation of this kind of UDC, we'll write a one-off if necessary but we also have a generic one called CODE_DESC_FORMAT. We use the Branch argument to pass in the name of the table and column that stores the code (i.e., Keys) and related descriptions.
Of course we all know what assumptions do
I just wanted to know if the combo box had a feature that allows you to associate input with output. But you have confirmed that it doesn't . I think it's weird that Revelation provided the feature for the radio control but not the drop down control.
Anyway, i will just have to create a global variable that maps the two things, no big deal.
We want to display
Visa
Mastercard
American Express
but the code requires
v
m
a
It would be nice if I could just do get_property(combo_box, "selected_value"), and get the appropriate code.
Thanks, I will give it a try.