Domanda

How to set the width of TextItem in DynamicForm?

Method TextItem#setWidth() is not working as expected.

I have tried DynamicForm#setColWidths() also but still unable to set the width.

Here is my code

import com.smartgwt.client.widgets.Window;
import com.smartgwt.client.widgets.form.DynamicForm;
import com.smartgwt.client.widgets.form.fields.TextItem;

public class AgeModelWindow extends Window {

public AgeModelWindow() {
    TextItem textItem = new TextItem();
    textItem.setWidth(50);
    textItem.setLength(3);
    textItem.setTitle("Age");

    DynamicForm form = new DynamicForm();
    form.setNumCols(2);
    //form.setColWidths("*", "50");
    form.setWidth100();
    form.setItems(textItem);

    this.setMargin(10);
    this.setTitle("Enter your age");

    this.addItem(form);

    this.setWidth(200);
    this.setHeight(100);
    this.setLeft(100);
    this.setTop(100);

    this.draw();
}

}
È stato utile?

Soluzione

I solved this issue using css styling on textItem. I don't know why it's not working via code in SmartGWT.

code:

textItem.setCellStyle("textItemAge"); 

css:

.textItemAge input,.textItemAgeFocused input,.textItemAgeDisabled input,.textItemAgeDisabledHint input,.textItemAgeError input,.textItemAgeHint input 
{ 
    width: 50px !important; 
}
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top