Is there a way to change the constraints of a DateTextBox dynamically in a onfocus event ?
I would like to change {min:} attribute so that the dates grayed can be changed dynamically.
Is there a way to change the constraints of a DateTextBox dynamically in a onfocus event ?
I would like to change {min:} attribute so that the dates grayed can be changed dynamically.
have you tried setting constraints.min?
You'd have to get the widget using dijit.byId() or .byNode()
tried setting constraints and also constraints.min
I tried setting constraints and also constraints.min, but does not seem to work. Here is
a snippet of what I tried:
retdate = dijit.byId('rdate');
retdate.constraints = "{min:'2008-01-01', max:'2010-01-01'}"
(this does not seem to work)
I also tried:
retdate.constraints.min = '2008-01-01';
use JavaScript Objects when in JavaScript
It should look something like this:
retdate.constraints = {min: Date(2008,0,1), max: Date(2010,0,1)};
or perhaps use a mixin to avoid clobbering other props
retdate.constraints = dojo.mixin(retdate.constraints, {min: Date...});
Does not seem to work with JavaScript objects too
Thanks for the suggestions.
Tried both (below). They do not work. The first seems to cause an error
as constraints gets mixed up. The second sets the constraints but
does not gray out the dates before Jan 2008-01-01. I am not sure
if the constraints are being checked each time the calendar is
displayed.
retdate.constraints = {min: Date(2008,0,1), max: Date(2010,0,1)};
retdate.constraints = dojo.mixin(retdate.constraints, {min: Date...});
sounds like a bug
http://trac.dojotoolkit.org/ticket/5610
In the meantime, it will likely work if you put these properties in the widget constructor, but I guess it should work at any point in the life of the widget?
I can't get this to work latest version 1.1
Can you tell me how to do this in dojo 1.1? We just went to the newest version and it says that this bug is fixed... if so, can you give me the code for min and max?... also can you use more the one constraint and have more than one constraint message accordingly? Or can you teach me how to programmically set it...here's what i'm trying:
from"
value = ""
constraints={datePattern:'MM/dd/yyyy'}, {min: Date(2006,0,1)}
onchange="rangeChange();"
required="true"
/>
Thanks for any help!
think of constraints as a single JS object
try the syntax {datePattern:'MM/dd/yyyy', min: new Date(2006,0,1)}
Did you figure this out?
I am attempting to dynamically set the min/max based on another date box so the end date must be after the start date and vice versa.
Did you find a working solution for this? Looking for a work around that I can use on 1.0.2 hopefully.
I got it working
I got it to work, I was using the incorrect date format.
For anyone that finds this thread and still needs to do this, here is a snippet to make it easier for you.
After doing this you will need to call postCreate on your widget or you will not see the new constraint reflected until you open and close the calendar once.
umm... that's not valid JS?
You shouldn't be dealing with date formats at all in your code. In JS, you should be using Date objects, in markup, ISO yyyy-mm-dd strings. So here, you should have something like
... {max: new Date(2006, 0, 1)}You are correct, I pasted
You are correct, I pasted the one I'd mentioned had issues on accident :)