SmartGwt DateItem useTextField=true - how to make text entry field UNeditable

天涯浪子 提交于 2019-12-02 01:08:05

问题


Since I can't figure out how to solve my problem presented here I'm thinking for the moment at a temporary solution.

I have a smartgwt DateItem widget:

DateItem date = new DateItem("Adate");
date.setWidth(120);
date.setWrapTitle(false);
date.setAttribute("useTextField", true); 
date.setAttribute("inputFormat", "yyyy/MM/dd");
date.setAttribute("displayFormat", "toJapanShortDate");

Because the attribute useTextField is set to true we can see the text entry field. How can I make this text entry field to be uneditable. Actually I want to have only the possibility to choose the date from calendar and not to change it manually.

Resolved - the issue exposed above - thanks to @RAS user.

TextItem textItem = new TextItem();
textItem.setAttribute("readOnly", true);
date.setAttribute("textFieldProperties", textItem); 

Related link

But I have now another issue (resolved - see here): The date chooser won't show the date on the text field but Today's date. For example, enter 30/05/2009 on the text field, go to another field, then come back on click on the date chooser and the selected day will be Today's date instead on June 30th, 2009. Which is the reason for this? Can this be solved?

Also let's say I let to the user to opportunity to manually modify the date - can I put some **validators on it?** (still need an ideea on this)

Thank you.


回答1:


date.setEnforceDate(true);

http://www.smartclient.com/smartgwt/javadoc/com/smartgwt/client/widgets/form/fields/DateItem.html#setEnforceDate%28java.lang.Boolean%29




回答2:


You have a lot of different validators. Depending on the context it must be possible to validate cardinality, relation to other data items, datatype(not only date time values) and relations to other external records.



来源:https://stackoverflow.com/questions/5009896/smartgwt-dateitem-usetextfield-true-how-to-make-text-entry-field-uneditable

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!