Reputation: 5825
I have several DateBox
widgets in a UiApp. With other widgets like TextBox
I can simply do something like:
UiApp.getElementById("someTextBox").setText("");
in order to make the field empty. When I do the same for DateBox
, the only value it can accept is a Date
Object, so the closest thing I can come to "empty" is today's date:
UiApp.getElementById("someDateBox").setValue(new Date());
I want the DateBox
to be empty when the UiInstance returns. Is there any way to accomplish this? Do I need to recreate the widget in order to have it be "empty"?
Edit: A solution, until a better method is implemented in the DateBox
class, is to re-create the widget entirely, and replace wherever is was located in the UiApp before. See Serge's Answer in a similar question.
Upvotes: 0
Views: 336
Reputation: 19864
You have just encountered one of the many flaws in that datebox. You will have to replace it. Beware of other problems. For example I filled an issue in the gas issues page about this: if a user ever selects a date and later clears the date box contents, your doGet will recieve the datebox previous non-empty value. Since you cant possibly detect an empty datebox from code and there is no visual indication to the user that they must fill the date, it was for me a showstopper so I moved to htmlServices and my own date box.
Upvotes: 1