CalendarXP.net Support Forum Index CalendarXP.net Support
Most forums here are private and invisible to public.
 
 FAQFAQ   SearchSearch   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

How to set the calendar range dynamically?

 
Post new topic   Reply to topic    CalendarXP.net Support Forum Index -> CalendarXP F.A.Q.
View previous topic :: View next topic  
Author Message
calendarxp
Site Admin


Joined: 30 Jan 2005
Posts: 409

PostPosted: Thu Feb 17, 2005 3:07 am    Post subject: How to set the calendar range dynamically? Reply with quote

For FlatCalendarXP, we just need to call the internal function fInitRange(range). e.g.
Code:
<script>
function modRange() {
  var beginDate=[2000,10,11];
  var endDate=[2020,2,21];
  if(self.gfFlat)gfFlat.fInitRange([beginDate,endDate]);
}
</script>
<input type="button" value="modify range" onclick="modRange()">

gfFlat is the context name defined in the name&id of your calendar iframe tag, and the range is an array with multiple elements (each element is an date array, e.g. [y,m,d]):
  1. indicates start of range;
  2. indicates end of range;
  3. indicates the default month to show if the init month falls out of the range;
  4. starting from the 4th element, each one indicates a date to be excluded (disabled) in the range.

e.g. the following will exclude Jan 3, 2002 and April 1, 2003 from the range started from Oct 11, 2000 and ended on Oct 11, 2004, with the fallback month set to Oct 2001.
Code:
gfFlat.fInitRange([[2000,10,11],[2004,10,11],[2001,10],[2002,1,3],[2003,4,1]]);


Note: any of these 4 elements can be set to null if not needed, however, the most important is the 3rd one - because without it the calendar may complain with an alert if the init month of the calendar falls out of range.

For PopCalendarXP, you may also pass the same range object as the 2nd parameter of the fPopCalendar() call. Following is an example, more details can be found in the HelloWorld tutorial.
Code:
gfPop.fPopCalendar(document.myform.mydate,[[1997,1,1],[2020,12,25],[2003,9]])


A good example in reality is that some people used the date range demo and wanted to limit the begin date to the existing value in another input box - it's just as easy as going into the plugins.js file, find the the definition of fStartPop() and modify it to be the following:
Code:
function fStartPop(startc,endc) {
  _startc=startc;
  _endc=endc;
  var sd=fParseInput(endc.value);
  if (!sd) sd=gEnd;
 
  var beginDate=fParseInput(gContainer.document.getElementById("id_of_the_input_tag").value);
  if (!beginDate) beginDate=gBegin;
  fPopCalendar(startc, [beginDate,sd,beginDate]);
}



Last but not least, you can override the fValidRange() in plugins.js and get full control of which days should be disabled. e.g. By appending the following code to agenda.js (not the plugins.js), it will ignore the setting of gBegin, gEnd and fInitRange(), and make all dates unavailable:
Code:
function fValidRange(y,m,d) {
  return false; // return false will disable date; true will enable date.
}

_________________
Copyright 2003-2011 Idemfactor Solutions, Inc. All rights reserved.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    CalendarXP.net Support Forum Index -> CalendarXP F.A.Q. All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum


Copyright 2003- Idemfactor Solutions, Inc. All rights reserved.
Powered by phpBB © 2001, 2005 phpBB Group