Announcement

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

    Getting the current displayed value of a select list

    OK, this is probably pretty easy, but I can't seem to find out how to do it. When a user is changing a select list item I want to be able to take an action of adding a tab (or if it is already added, just change its title and contents) and set that tab's title to the display text of the select box. Any hints? thanks...

    #2
    Pretty straightforward - add a change() handler to the field - e.g:

    Code:
    isc.DynamicForm.create({
        fields: [
            {name: "foo",
              valueMap: {
                  foo: "Bar"
              }
              change : function form, item, value, oldValue) {
                  //create your tab here
              }
             }
        ]
    });
    change() handler docs are here: http://www.smartclient.com/docs/5.5....ormItem.change

    Comment


      #3
      pretty straight forward except for getting that new Display value that will become the name of the new tab. I read in the documentation that in the change handler the new value hasn't been set yet, so calling item.getDisplayValue() wouldn't be useful. And indeed it returns 'undefined' when called within the change handler.

      I would hate to have to create a whole new service and ajax call to get the string corresponding to the new value especially since the data is already sitting in the datasource and in the valueMap of the select box, I just don't know how to get at it. I figured calling something like item.getValueMap() might work, but no go. Any other options I can look into?

      Comment


        #4
        Hi jjohns,

        We've added support to getDisplayValue() to allow you to pass in a value instead of relying on the current value of the form. In the meantime, you can use the undocumented formItem.mapValueToDisplay(storedValue) to get the current display value (if there is one and it's been loaded).

        Comment


          #5
          For the benefit of people who discover this thread while searching the forums:

          As of version 10.1 (SmartGWT 5.1), the mapValueToDisplay() method has been made public as a callable API only (ie, not as an override point).

          Comment

          Working...
          X