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

Insert forces user to edit inline, then validates.

9 Answers 100 Views
Scheduler
This is a migrated thread and some comments may be shown as answers.
Alan
Top achievements
Rank 1
Alan asked on 11 Jan 2011, 01:06 PM
I have a scenario where the only way a user can create an appointment, is by dragging from a RadTreeView. The requirement is that when the user drags the appointment, and before the appointment is created, the user is required to enter the appointment's description, and then some validation needs to run before the appointment is actually committed.

What's the easiest way to achieving this? (assuming of course that it's possible.)

Many thanks,
Daryl

9 Answers, 1 is accepted

Sort by
0
Alan
Top achievements
Rank 1
answered on 13 Jan 2011, 02:16 PM
bump
0
Peter
Telerik team
answered on 13 Jan 2011, 07:46 PM
Hello Daryl,


<form id="form1" runat="server">
    <telerik:RadScriptManager ID="RadScriptManager1" runat="server">
    </telerik:RadScriptManager>
    <telerik:RadScriptBlock ID="RadScriptBlock1" runat="server">
        <script type="text/javascript">
            
            function nodeDropping(sender, eventArgs) {
                // Fired when the user drops a TreeView node
                var node = eventArgs.get_sourceNode();
                var text = node.get_text();
  
                document.getElementById("HiddenField1").value = text;
  
                var htmlElement = eventArgs.get_htmlElement();
                var scheduler = $find('<%= RadScheduler1.ClientID %>');
  
                if (isPartOfSchedulerAppointmentArea(htmlElement)) {
                    // The node was dropped over the scheduler appointment area
  
                    var timeSlot = scheduler.get_activeModel().getTimeSlotFromDomElement(htmlElement)
  
//                    var newAppointment = new Telerik.Web.UI.SchedulerAppointment();
//                    var startTime = timeSlot.get_startTime();
  
//                    var endTime = new Date(startTime);
//                    endTime.setMinutes(endTime.getMinutes() + 60);
  
//                    newAppointment.set_start(startTime);
//                    newAppointment.set_end(endTime);
//                    newAppointment.set_subject(text);
//                    scheduler.insertAppointment(newAppointment);                   
  
                      scheduler.showInsertFormAt(timeSlot);
                }
                else {
                    // The node was dropped elsewhere on the document
                    eventArgs.set_cancel(true);
                }
            }
            function isPartOfSchedulerAppointmentArea(htmlElement) {
                // Determines if an html element is part of the scheduler appointment area
                // This can be either the rsContent or the rsAllDay div (in day and week view)
                return $telerik.$(htmlElement).parents().is("div.rsAllDay") ||
                            $telerik.$(htmlElement).parents().is("div.rsContent")
            }    
                 
        </script>
    </telerik:RadScriptBlock>
    <asp:HiddenField ID="HiddenField1" runat="server" />
    <telerik:RadTreeView ID="RadTreeView1" runat="server" EnableDragAndDrop="True" OnClientNodeDropping="nodeDropping">
        <Nodes>
            <telerik:RadTreeNode runat="server" Value="1" Text="Alex">
            </telerik:RadTreeNode>
            <telerik:RadTreeNode runat="server" Value="2" Text="Bob">
            </telerik:RadTreeNode>
            <telerik:RadTreeNode runat="server" Value="3" Text="Charlie">
            </telerik:RadTreeNode>
        </Nodes>
        <CollapseAnimation Duration="100" Type="OutQuint" />
        <ExpandAnimation Duration="100" />
    </telerik:RadTreeView>
    <br />
    <br />
    <telerik:RadScheduler runat="server" ID="RadScheduler1" StartInsertingInAdvancedForm="true"
    GroupBy="Room"
        EnableDescriptionField="true" onformcreating="RadScheduler1_FormCreating">
        <AdvancedForm Modal="true" />
    </telerik:RadScheduler>
    </form>

protected void RadScheduler1_FormCreating(object sender, SchedulerFormCreatingEventArgs e)
   {
       if (e.Mode == SchedulerFormMode.AdvancedInsert)
       {
           e.Appointment.Subject = HiddenField1.Value;
           HiddenField1.Value = null;
       }
   }



All the best,
Peter
the Telerik team
Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.
0
Alan
Top achievements
Rank 1
answered on 17 Jan 2011, 10:38 AM
Sorry for the late reply.

I implemented that code but nothing happens (radScheduler_FormCreating is not fired).

Even though it didn't I noticed that this is an advanced form insert, although this would probably be accepted, it would be better if it's just the description and inline not advanced form.

Many Thanks,
Daryl
0
Peter
Telerik team
answered on 17 Jan 2011, 01:44 PM
Hi Daryl,

I am not sure why the event does not fire at your end, but you can open the inline edit form instead of the advanced form by setting StartInsertingInAdvancedForm="false" and modifying the code behind like this:

protected void RadScheduler1_FormCreating(object sender, SchedulerFormCreatingEventArgs e)
  {
      if (e.Mode == SchedulerFormMode.AdvancedInsert || e.Mode == SchedulerFormMode.Insert)
      {
          e.Appointment.Subject = HiddenField1.Value;
          HiddenField1.Value = null;
      }
  }


Regards,
Peter
the Telerik team
Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.
0
Alan
Top achievements
Rank 1
answered on 17 Jan 2011, 02:34 PM
My bad, I already had the drag drop code so I modified it instead of copy paste, because I'm doing some other stuff. I forgot to add:
scheduler.showInsertFormAt(timeSlot);

One more question, the inline template is great, all I need is one multi-line textbox, but it's setting subject not description. Is there a way of changing that (a property) or do I have to create an inline template?

Thanks,
Daryl
0
Peter
Telerik team
answered on 17 Jan 2011, 02:46 PM
Hi Daryl,

Once you enable the description field, then you FormCreating you can set:

e.Appointment.Description = HiddenField1.Value;

However, it will not be visible. If you need to display it in the inline insert form you should use InlineInsertTemplate.


All the best,
Peter
the Telerik team
Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.
0
Alan
Top achievements
Rank 1
answered on 17 Jan 2011, 02:53 PM
That's what I thought, and tried.

However when AppointmentInsert is triggered, e.Appointment.Description is empty, and the value inserted in the textbox is set to e.Appointment.Subject.
0
Peter
Telerik team
answered on 17 Jan 2011, 02:58 PM

Indeed, this is happening because the description field is not visible in the inline insert form. Sorry for misleading you. In that case you can handle AppointmentInsert and set e.Appointment.Description = HiddenField1.Value;


Peter
the Telerik team
Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.
0
Alan
Top achievements
Rank 1
answered on 17 Jan 2011, 03:07 PM
Thanks for the prompt reply!

Thanks, I can do that. I have to swap the values of subject with description. Because Scheduler is automatically setting the multi-line textbox as subject.

Anyway, thanks again for your help.
Tags
Scheduler
Asked by
Alan
Top achievements
Rank 1
Answers by
Alan
Top achievements
Rank 1
Peter
Telerik team
Share this question
or