smartgwt version
Version v9.1p_2014-06-30/Enterprise Deployment (2014-06-30)
browser
Chrome
Statictextitem does not wrap value in chrome (works in IE and FF)
Version v9.1p_2014-06-30/Enterprise Deployment (2014-06-30)
browser
Chrome
Statictextitem does not wrap value in chrome (works in IE and FF)
Code:
import com.google.gwt.core.client.EntryPoint; import com.smartgwt.client.types.Alignment; import com.smartgwt.client.types.Overflow; import com.smartgwt.client.types.TitleOrientation; import com.smartgwt.client.widgets.Canvas; import com.smartgwt.client.widgets.form.DynamicForm; import com.smartgwt.client.widgets.form.fields.StaticTextItem; import com.smartgwt.client.widgets.form.fields.TextAreaItem; import com.smartgwt.client.widgets.form.fields.events.ChangedEvent; import com.smartgwt.client.widgets.form.fields.events.ChangedHandler; import com.smartgwt.client.widgets.form.validator.LengthRangeValidator; public class StaticItemTest implements EntryPoint { public void onModuleLoad() { LengthRangeValidator descValidator = new LengthRangeValidator(); descValidator.setMin(0); descValidator.setMax(500); descValidator.setErrorMessage("Description must be between 0 and 500 characters"); TextAreaItem descTextAreaItem = new TextAreaItem("description", "Description"); descTextAreaItem.setTitleAlign(Alignment.RIGHT); descTextAreaItem.setWidth(300); descTextAreaItem.setHeight(64); descTextAreaItem.setValidateOnChange(true); descTextAreaItem.setValidators(descValidator); descTextAreaItem.setShowHint(false); StaticTextItem descHint = new StaticTextItem(); descTextAreaItem.addChangedHandler(new HintUpdatingChangedHandler(500, descHint)); DynamicForm form = new DynamicForm(); form.setNumCols(3); form.setTitleOrientation(TitleOrientation.LEFT); form.setTitleSuffix(": "); form.setCellPadding(2); form.setWrapItemTitles(false); form.setFields(descTextAreaItem, descHint); Canvas canvas = new Canvas(); canvas.setBorder("2px solid red"); canvas.setWidth(450); canvas.setOverflow(Overflow.AUTO); canvas.addChild(form); canvas.draw(); } class HintUpdatingChangedHandler implements ChangedHandler { private int maxLength; StaticTextItem textItem; public HintUpdatingChangedHandler(int maxLength,StaticTextItem item) { this.maxLength = maxLength; textItem=item; if(textItem !=null) textItem.setShowTitle(false); } public void onChanged(ChangedEvent event) { if(textItem !=null) { textItem.setValue(getCharsRemainingText((String) event.getValue(), maxLength)); }else { event.getItem().setHint(getCharsRemainingText((String) event.getValue(), maxLength)); } } public String getCharsRemainingText(String value, int maxLength) { int count = (value == null) ? 0 : value.length(); return "<nobr> (" + (maxLength-count) +" of " + maxLength + " characters left)"; } } }
Comment