Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    how to get the displayed value from a field

    I have a ListGrid which is using an optionDataSource and I wanted to retrieve the displayed value.

    I found that I can get the ListGridField's valueMap through

    Code:
    	Map valueMap = field.getAttributeAsMap("valueMap");
    and get the displayed value from the map.

    Is there a better way to do this, or is this reasonable?

    #2
    What component do you want to use for the map?

    ComboBoxItem SelectItem ?

    Cheers,

    EJ

    Comment


      #3
      It was a SelectItem I believe.

      Comment


        #4
        You can use the following:

        Code:
                SelectItem item = new SelectItem("theField");
                ufNatal.setDisplayField("name_of_display_on_option_datasource");
                ufNatal.setValueField("name_of_value_on_option_datasource");
        On option datasource set the fields you want to both display and use as value.

        Hope that helps.

        Cheers,
        EJ

        Comment


          #5
          Thank you for trying to help, but I don't think that solves the problem.

          Say I have a record that is currently being displayed by the SelectItem. I can grab the value from the Select item, since that is the only thing that is actually stored in the record. But how can I get the displayed value? That is what I was using the map for, as above. I'm not sure there is an API to do this - aside from doing a fetch on the option DataSource to do the lookup, which I think is probably the more correct solution than grabbing the valuemap.

          Comment


            #6
            Originally posted by atomatom
            Thank you for trying to help, but I don't think that solves the problem.

            Say I have a record that is currently being displayed by the SelectItem. I can grab the value from the Select item, since that is the only thing that is actually stored in the record. But how can I get the displayed value? That is what I was using the map for, as above. I'm not sure there is an API to do this - aside from doing a fetch on the option DataSource to do the lookup, which I think is probably the more correct solution than grabbing the valuemap.
            How is your optiondatasource defined?

            What about the main datasource?

            Cheers,

            EJ

            Comment

            Working...
            X