Announcement

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

    How to Update DataSourceTextField Value Map

    SmartGWT 2.4

    We're using a ListGrid using a custom DataSource. In our customer datasource, one of the fields is a DataSourceTextField in which we set a valueMap from which a user can select a value for that field. This value map is supposed to change values depending on what are already chosen. However, I cannot get the dropdown options to update. I've tried calling DataSourceTextField.setValueMap() multiple times to do the update but the dropdown fox is never refreshed.

    How does one update the value map in a field with new values whenever they need to be changed.

    #2
    Hi Richip,

    are you trying to do something similar to this ?

    http://forums.smartclient.com/showthread.php?t=19330

    Comment


      #3
      Not quite. That thread talks about having a different data source value map per record in the ListGrid (no mention on whether the original poster wants each to change in time). My requirements are slightly simpler. I just need to be able to change the value map associated with the data source for a field at any point in time. Right now, it looks like it's only static. Once a value map or array is set, there doesn't seem to be a way to change it.

      It's the same value map for all the records. It just needs to change in time.

      Comment


        #4
        Perhaps the ListGridField.setEditorValueMapFunction() will do the trick for you ?

        Comment


          #5
          Thank you! That did the trick! Though it does have a nasty side effect:

          Currently, we're using a Map object for the ValueMap. Once the valuemap is changed, the display text reverts to the map key. My objective was to make sure that each record for a particular field is unique so everytime a record is selected, I modify the Map and remove all those records that are already selected.

          Comment


            #6
            You could also do that in the Grid level (that's what im doing). here a sample :

            Code:
            detailedGrid.setEditorCustomizer(new ListGridEditorCustomizer()
            		{
            
            			@Override
            			public FormItem getEditor(ListGridEditorContext context)
            			{
            				SelectItem sI = new SelectItem();
            				sI.setValueMap("test","test2");
            				return sI;
            			}
            		});
            That way, everytime the user edit a field, I construct a new SelectItem. In your case, I think it could also work.

            Comment


              #7
              Do you know in which version of SmartGWT ListGrid.setEditorCustomizer was introduced?

              Comment


                #8
                according to http://www.smartclient.com/smartgwt/...notes.html#2_5 it was on version 2.5

                Comment

                Working...
                X