Announcement

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

    DynamicForm SelectItem

    I'm looking for the best approach to have a SelectItem display in a DynamicForm where its ValueMap (choices) are statically defined but the user's selected value will persist with the record associated with the dynamic form.

    If I use a SelectItem type then I can set the ValueMap which takes care of the statically defined choices, but I don't get any control over the Item's placement on the form like I do when the field is declared as a FormItem (e.g. setColSpan ) which is important for the form as its quite extensive.

    I've tried using setType("selectItem") on the FormItem but it doesn't work - at least not for me.

    Any advice?

    #2
    There's no difference in field order from using FormItem vs SelectItem. It's not clear why you're seeing this - have you already read the DataBinding chapter of the QuickStart?

    Comment


      #3
      I read the chapter and I've looked through the examples but can't seem to find an answer. Perhaps I can restate it a different way.

      I am trying to design a dynamic form which displays a field called Currency. The field is to be displayed as a drop down list on the form (hence SelectItem), and the value saved in the current record associated with the form. As you can see from below, I'm trying to use a static list for the Value Map. When I run this the field just shows as an empty text box.

      Code fragment:
      form = new DynamicForm();
      form.setDataSource(someDS);

      FormItem currency = form.getField("currency");
      currency.setStartRow(true);
      currency.setColSpan(3);
      currency.setType("selectItem");
      currency.setValueMap("USD", "CAD", "GBP", "HKD");

      I guess I must be missing something but I don't know what.

      Comment


        #4
        Why are you doing new FormItem() instead of new SelectItem()?

        Comment


          #5
          I'm not. I was using <DynamicForm>.getField("currency") followed by <FormItem>.setType("selectItem") as a hint to SmartGWT. But it doesn't seem to pick it up.

          I think I have a workaround by instantiating these form fields directly (e.g. new SelectItem() ) and then just registering it with the form via <DynamicFields>.setFields(). Seems to work so far but I haven't completely tested it all the way through.

          Comment


            #6
            ? That's not a workaround, that's what the DataBinding chapter tells you to do! :)

            Comment


              #7
              I know, but some of the examples use the other style which I thought might require less coding on my part. Anyway, I think my understanding in this area is more illuminated now. Thanks for your quick responses.

              Comment

              Working...
              X