create event on double click of cell

2 posts, 1 answers
  1. Nithin
    Nithin avatar
    67 posts
    Member since:
    Mar 2018

    Posted 16 May 2018 Link to this post

    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 

  2. Answer
    Dimitar
    Admin
    Dimitar avatar
    796 posts

    Posted 18 May 2018 Link to this post

    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.
Back to Top