This is a migrated thread and some comments may be shown as answers.

Current month in RadCalendar?

3 Answers 253 Views
Calendar
This is a migrated thread and some comments may be shown as answers.
Mantas
Top achievements
Rank 1
Mantas asked on 05 Mar 2009, 12:52 PM
Hi,

Can anyone tell me how can I get current month on client-side? I need to fire web service on OnCalendarViewChanged and pass current month. Something like:

<script type="text/javascript">
 
function ViewChanged(sender, eventArgs)
 {
   var month = getMonth();
  myWebServiceMethod(month); 

 }
<
/script>
<
telerik:RadCalendar ID="RadCalendar1" runat="server">
 
<ClientEvents OnCalendarViewChanged="ViewChanged" />
</
telerik:RadCalendar>


-Mantas-

3 Answers, 1 is accepted

Sort by
0
Daniel
Telerik team
answered on 05 Mar 2009, 02:51 PM
Hello Mantas,

I modified your code a bit:
    function ViewChanged(sender, eventArgs) 
    { 
        var month = sender.get_focusedDate()[1]; 
        //... 
    } 

Let us know if we can assist you further.

Best regards,
Daniel
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
Mantas
Top achievements
Rank 1
answered on 06 Mar 2009, 02:05 PM
Hi,
Thanks a lot for quick answer, that was what I needed. However, now I ran into another problem and whatever I do I can’t get to work around it. To make this short, I need to fire webservise method when user navigates to a different month. Then to fill RadCalendar cells with received results. To solve this I tried to used onCalendarViewChanged and onDateRender, Something like:
//-------------------------------------------------------------------------------------
    var _result;
    var _loaded;

 function onDateRender(sender, eventArgs) {
    if( _loaded == false) {
             var month = sender.get_focusedDate()[1];
              MyWebserviceMethod(month, OnSuccess);
             _loaded = true;
         } 
   var cell = eventArgs.get_cell();
   cell.innerHTML += fillCell( _result );
}

 function  onCalendarViewChanged (sender, eventArgs) {
     _loaded = false;
}      

function onSuccess(result) {
        _result = result;
    }
//------------------------------------------------------------------------------------

The problem with that is that RadCalendar finishes render before webservice returns required data. I guess all of this could be easily solved if I could just trigger RadCalander to re-render itself on onSuccess once I am sure that I received required data. Is there a way to refresh the RadCalendar or maybe someone has better ideas on how to achieve these aims?

Mantas


0
Accepted
Daniel
Telerik team
answered on 10 Mar 2009, 04:25 PM
Hello Mantas,

Try the following approach:
var _result; 
var _loaded; 
 
function onDateRender(sender, eventArgs)  
    if( _loaded == false)  
    { 
        var month = sender.get_focusedDate()[1]; 
        _loaded = true
    }  
    var cell = eventArgs.get_cell(); 
    MyWebserviceMethod(month, OnSuccess,null,cell); 
 
function onCalendarViewChanged (sender, eventArgs)  
     _loaded = false
}       
 
function onSuccess(result,cell)  
    cell.innerHTML += fillCell( _result ); 
    _result = result; 

Regards,
Daniel
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
Tags
Calendar
Asked by
Mantas
Top achievements
Rank 1
Answers by
Daniel
Telerik team
Mantas
Top achievements
Rank 1
Share this question
or