Search code examples
javagwtsmartgwt

smartgwt - DynamicForm relative column width


If i create a DynamicForm as shown below the FormItems of the DynamicForm are placed over 2 rows. I expected them to be in one row. The place should be distributed as folowing: 20 px for the first column, 250 for the second and the rest for the third.

final DynamicForm df = new DynamicForm();
FormItem[] fi = new FormItem[3];
// filling the list with one CheckboxItem, one TextItem and one SelectItem
df.setColWidths("20", "250", "*");
df.setNumCols(3);
df.setFields(fi);

The result looks like this:

result screenshot

I wanted to have all FormItems in one row.


Solution

  • Basically title of form item also takes one column. If you do want to show the title also then it will double the column count.

    For more info have a look at DynamicForm#setColWidths().


    As per you comment:

    //filling the list with one CheckboxItem, one TextItem and one SelectItem?
    

    Try this one:

        final DynamicForm df = new DynamicForm();
        // FormItem[] fi = new FormItem[3];
        // filling the list with one CheckboxItem, one TextItem and one SelectItem
    
        CheckboxItem ci = new CheckboxItem();
        ci.setShowTitle(false);
        ci.setTitle("");
    
        TextItem ti = new TextItem();
        ti.setShowTitle(false);
    
        SelectItem si = new SelectItem();
        si.setShowTitle(false);
        si.setValues("PDF");
    
        df.setItems(ci, ti, si);
    
        df.setColWidths("20", "250", "*");
        df.setNumCols(3);
        // df.setFields(fi);
    
        RootPanel.get().add(df);
    

    Snapshot:

    enter image description here


    As per your snapshot:

    Try this one

        final DynamicForm df = new DynamicForm();
        // FormItem[] fi = new FormItem[3];
    
        CheckboxItem ci = new CheckboxItem();
        ci.setShowTitle(false);
        ci.setTitle("");
    
        SelectItem si = new SelectItem();
        si.setTitle("LANGUAGE");
        si.setValues("PDF");
    
        df.setItems(ci, si);
    
        df.setColWidths("20", "250", "*");
        df.setNumCols(3);
        // df.setFields(fi);
    
        RootPanel.get().add(df);
    

    Snapshot:

    enter image description here