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

create event on double click of cell

1 Answer 451 Views
Scheduler
This is a migrated thread and some comments may be shown as answers.
Nithin
Top achievements
Rank 1
Nithin asked on 16 May 2018, 01:25 PM

Hi,
I'm trying to create an event on double click on a selected cell in the scheduler.
I have already implemented right click and drag event create and left click and create event 

The below code is for create event on right click and drag

view.element.on("mouseup", ".k-scheduler-content td", function(e) {
  if(e.which===1){     
 
     let scheduler = this;
     let selection = scheduler.select();
     let slot = scheduler.slotByElement($(e.target));
     let resource = scheduler.resourcesBySlot(slot);
     let roomId = resource.RoomID;
 
     if (selection.events && !selection.events.length ) {
      if(selection.slots.length>1){
         //no events are selected then this is create
          scheduler.select(null);
          scheduler.addEvent({
             reservationId:newResNumber,
               title:"No Title",
              FirstName:"Jane",
               LastName:"Doe",
               start: selection.start,
               end: selection.end,
               RenderColor:"#FFFFCE",
               RoomID: roomId,
               CheckedIn:true,
               Moveable:true
           });
         }
        }
}
});

 

How can i create event on double click on a selected event 

1 Answer, 1 is accepted

Sort by
0
Accepted
Dimitar
Telerik team
answered on 18 May 2018, 11:11 AM
Hi Nithin,

If I can understand you correctly, you would like to programmatically add an event to the Scheduler widget without triggering the create window. This can be achieved by defining a simple object that holds the desired event data and then using the dataSource's add() method to push the item:
<script>
  scheduler.view().element.on("dblclick", ".k-scheduler-content td", function(e) {             
    var event = {
      id: 1,
      title: "Eventasdasdasdas",
      start: new Date("2013/6/13 07:00 AM"),
      end: new Date("2013/6/13 09:00 AM")
    };
   
    scheduler.dataSource.add(event);      
  });
</script>

In addition to the above, the default behavior when you doubleclick in the Scheduler content area is to open the create event popup. In this specific scenario the default action needs to be prevented. This can be done in the edit event of the Scheduler:
<script>
  var scheduler = $("#scheduler").kendoScheduler({
    ...
    edit: function(e) {
      e.preventDefault();
    }
  });
</script>


The above is also demonstrated on the following Dojo example.

Regards,
Dimitar
Progress Telerik
Try our brand new, jQuery-free Angular components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
Tags
Scheduler
Asked by
Nithin
Top achievements
Rank 1
Answers by
Dimitar
Telerik team
Share this question
or