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?

edited March 2020 in OpenInsight
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.

Comments

  • Are you simply asking if the combo box control can be associated with the database like so:

  • Hi,

    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.
  • I recommend subclassing
    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


  • edited March 2020
    I don't know anything about subclassing. I am curious to learn more, as I could probably make use of it .

    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.
  • 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.

    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.
  • Don,
    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.


  • I will be interested to see if Josh responds to confirm or clarify his intent. Until then, I think his second email is rather clear:
    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.

    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.
  • edited April 2020
    ah yes. I took his third entry
    I would like to create a combo box whose drop down contains images
    and subconsciously combined it with his image inside combobox post to make an assumption about the colours.

    Of course we all know what assumptions do


  • edited April 2020
    Hi,

    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.
  • Did you not like the idea of a UDC or are you not familiar with it? It really is a better approach than creating a global variable. The latter approach requires a lot of custom management simply to support a UI convenience.
  • edited April 2020
    I have never heard of the concept of a UDC in OI. Btw, this is in the context of allowing the user to choose a credit card type.

    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.
  • SMH...I'm usually the one who remembers what we've published in our blog. Thanks for linking to that article Kevin!
  • Oh, so this is basically a custom CONV function.

    Thanks, I will give it a try.
  • edited April 2020
    actually, I misremeber. I have done something like this before for days of the week. Thank you for reminding me about this. I will definitely use it.
Sign In or Register to comment.