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

OnClientAppointmentInserting from Custom Control

6 Answers 126 Views
Scheduler
This is a migrated thread and some comments may be shown as answers.
Michael J.
Top achievements
Rank 1
Michael J. asked on 05 May 2009, 08:43 PM
Just above my RAD Scheduler, I've placed a hyperlink that says "Add a New Appointment".  If double-clicking the RAD Scheduler cell to add a new Appointment isn't intuitive enough for the average User, then the User should know enough to click this link.

I currently have the click event of this link wired up to the JavaScript AppointmentInserting event.  When this event is invoked by double-clicking the RAD Scheduler date cell to add a new Event, I have access to the passed in (sender, eventArgs) values.  Several values are set, our custom Advanced Edit form opens with a modal underlay, and everything works as expected.

Going back to the new hyperlink I've added, I would like the click event of the link to replicate the same functionality as above.  However, I do not have access to the (sender, eventArgs) values.  Ideally, I would like to trick the event handler into thinking that the event was fired from the RAD Scheduler.  Because I do not have access to the (sender, eventArgs) values, the JS event does not function as expected.  The Advances Edit form opens with a modal underlay, but it is soon blown away because I wasn't able to successfully call eventArgs.setCancel(true).

Is this functionality possible? For your reference, I've posted my code below.

Thanks!
Mike

------------------------------------------------------------------------------------------------------------------

<div>   
   
 
 
 
   
 
   
 
<asp:LinkButton ID="lbAddNewSchedulerEvent" OnClientClick="javascript:AppointmentInserting();" runat="server">Add New Scheduler Event</asp:LinkButton>   
   
 
 
 
</div>  
 
<div>   
   
 
   
 
   
 
   
 
   
 
<telerik:RadScheduler  
........  
</telerik:RadScheduler>   
   
 
   
 
   
 
   
 
</  
 
   
 
 
 
div>  
 
function AppointmentInserting(sender, eventArgs)   
   
 
   
 
   
 
{  
 
   
 
    try   
    {  
        var start = formatDate(eventArgs.get_startTime());   
    }  
 
 
 
   
 
   
 
    catch (e)   
    {  
 
 
 
   
 
        var start = "01/01/2009";   
    }  
 
   
 
 
 
 
    try    
   
 
   
 
    {  
 
 
 
   
 
        var isAllDay = eventArgs.get_isAllDay();   
    }  
 
 
 
   
 
    catch (e)   
    {  
 
 
 
   
 
        var isAllDay = true;   
    }  
 
 
 
   
 
    //New appointment    
    window.radopen(  
 
 
 
   
 
    "DefaultTemplates/AdvancedForm.aspx?Mode=Insert&Start=" + start + "&IsAllDay=" + isAllDay, "AdvancedForm");   
   
 
 
 
    try    
    {   
   
 
        eventArgs.set_cancel(  
 
 
 
true);   
    }   
   
 
 
 
   
 
    catch (e)   
    {  
 
        alert(  
 
 
 
"I need to make sure the Advanced Edit form doesn't close here...How can I invoke a Cancel??");   
   
 
        alert(e);  
 
    }  
}  
 
 
 
 
 

 

 

 

 

 

 

 

 

 

6 Answers, 1 is accepted

Sort by
0
Michael J.
Top achievements
Rank 1
answered on 07 May 2009, 12:17 PM
Nothing?  Does anyone understand what I'm trying to accomplish?
0
Accepted
Veselin Vasilev
Telerik team
answered on 08 May 2009, 02:06 PM
Hi Michael J.,

You can do it. You just need to hard code the start time of the appointment that is being created.
There are two approaches:
  • client-side - use the showInsertFormAt method of the RadScheduler object. It expects a timeslot argument. 
  • server-side - use the ShowInlineInsertForm or ShowAdvancedInsertForm methods of RadScheduler. You need to pass a DateTime object as a parameter.

Please find attached a sample project.

Greetings,
Veselin Vasilev
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
Michael J.
Top achievements
Rank 1
answered on 08 May 2009, 04:22 PM
Thank you, Veselin Vasilev.

I will pursue this example and let you know if I have any questions.

I appreciate your help!

Michael
0
Michael J.
Top achievements
Rank 1
answered on 08 May 2009, 07:05 PM
For closure to this topic, please know that the provided solution has worked.

Thanks,
Mike
0
Clyde
Top achievements
Rank 1
answered on 13 May 2009, 09:23 PM
I am trying something similar, but need to rather Edit an appointment from a hyperlink within a RadGrid. I have a list of appointments in the grid and would like the Edit Appointment event to be called with the Appointment.ID. Is this possible? And how would I do it.

To add a complication, I'm using the Scheduler using the RadDock form example as the base for this functionality.

Any help would really be appreciated.

Thanks
Clyde
0
Veselin Vasilev
Telerik team
answered on 18 May 2009, 09:22 AM
Hi Clyde,

You can use the ShowAdvancedEditForm server method of RadScheduler. You just need to pass the appointment as a parameter.

Sincerely yours,
Veselin Vasilev
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
Scheduler
Asked by
Michael J.
Top achievements
Rank 1
Answers by
Michael J.
Top achievements
Rank 1
Veselin Vasilev
Telerik team
Clyde
Top achievements
Rank 1
Share this question
or