Announcement

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

    Dynamic form item in grid list

    I'm working with a SmartGWT grid that has two fields. The second field needs to dynamically switch between a SelectItem and a TextItem based on the chosen value in the first field (which is also a SelectItem). Could you provide some code to achieve this functionality?

    #2
    If you'd like such code written for you, we offer Consulting services (billed hourly).

    Otherwise, a common approach would be to use formItem.visibleWhen to declaratively control which item is visible.

    Comment


      #3
      Hi lukepham90

      see the code below. I have a non-editable first "type"-column and depending on that column I choose an editor.
      You'll also need to look into context.getEditField() to always return a TextItem (?) for your 1st column and sth similar to my code for your second column:
      Code:
      setEditorCustomizer(new ListGridEditorCustomizer() {
                  public FormItem getEditor(ListGridEditorContext context) {
                      String firstField = context.getEditedRecord().getAttributeAsString("firstField");
                      if (firstField.equals("selectYesNo")) {
                          return new SelectItemYesNo();
                      } else if (firstField.equals("bigfield") {
                          return new TextAreaItem();
                      } else {
                          return new TextItem();
                      }
                  }
              });
      Also see this sample.

      Best regards
      Blama

      Comment

      Working...
      X