Calendar

Calendar Basic

Calendar component is used to input Date and time, it explains how to implement function.

Cablendar_Basic_0

DataSet Binding

Celendar can be represted by DataSet binding

Various representation of Type

We can implement various expressions using normal, spin, monthly and other property of Calendar.

Setting Default Date

this.Calendar_Basic_onload = function (obj:Form, e:LoadEventInfo)
{
    this.cal_today.set_expr("expr:comp.parent.Today()");
    this.cal_before.set_expr("expr:comp.parent.before()");
    this.cal_last.set_expr("expr:comp.parent.Last()");  
}
We can set default value of Calendar from onload event of form.
this.Today = function ()
{
    var sToday = "";
    var objDate = new Date();
    var sToday  = objDate.getFullYear() + "";
    var sMonth = objDate.getMonth()+1;
    var sDate = objDate.getDate();
    
    if(sMonth.toString().length == 1){
      sMonth = "0" + sMonth;
    }
    if(sDate.toString().length == 1){
      sDate = "0" + sDate;
    }
    sToday = sToday+sMonth+sDate;    
    return sToday;
}
this.before = function ()
{
    var bDate = "";
    var objDate = new Date();
    objDate.addDate(-1);
    var bDate  = objDate.getFullYear() + "";
    var sMonth = objDate.getMonth()+1;
    var sDate = objDate.getDate();
    if(sMonth.toString().length == 1){
       sMonth = "0" + sMonth;
    }
    if(sDate.toString().length == 1){
       sDate = "0" + sDate;
    }
    bDate = bDate+sMonth+sDate;
    return bDate;
   
}    
this.Last = function ()
{
    var objDate2 = new Date();
    objDate2.addMonth(1);
    objDate2.setDate(1);
    objDate2.addDate(-1);
    var last_date  = objDate2.getFullYear() + "";
    var sMonth = objDate2.getMonth()+1;
    var sDate = objDate2.getDate();
    if(sMonth.toString().length == 1){
       sMonth = "0" + sMonth;
    }
    if(sDate.toString().length == 1)
    {
       sDate = "0" + sDate;
    }
    last_date = last_date+sMonth+sDate;
    return last_date;
}

Can we represent date in Spin format of date component?

Source Location

Sample\Calendar\np_Calendar_Basic.xfdl