SmartGwt DateItem useTextField=true - how to make

2019-02-24 23:55发布

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.

2条回答
Root(大扎)
2楼-- · 2019-02-25 00:15

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.

查看更多
登录 后发表回答