[CLOSED] How to copy an event using Ext.Net CalendarPanel ?

  1. #1

    [CLOSED] How to copy an event using Ext.Net CalendarPanel ?

    Hi,

    I am using CalendarPanel for time booking application. In this I need to copy existing Event to a new date (as is) and then resize the event. Is there any event to achieve this ?

    Thanks
    PRASAD
  2. #2
    You have to create new record in EventStore with required data
    The code can be look like this
    var rec = App.EventStore1.getAt(0).copy(); 
    rec.set("StartDate", new Date(....)); 
    rec.set("EndDate", new Date(....));
    App.EventStore1.add(rec);
  3. #3
    Thanks for your code.

    From where should I give a call to this code as I could not find relevant event in CalendarPanel Listners. Please suggest.
  4. #4
    Quote Originally Posted by Arohan View Post
    Thanks for your code.

    From where should I give a call to this code as I could not find relevant event in CalendarPanel Listners. Please suggest.
    You can execute this code from any Listener. You mentioned you need to 'copy' the record... what will trigger the copy?
    Geoffrey McGill
    Founder
  5. #5
    Any of the following method will do

    1. CTRL-Drag-Drop (as drag drop is already used by EventMove)
    2. CTRL-C+CTRL-V


    Or is there any ready event for EventCopy (as CalandarPanel already have EventMove, EventResize, EventAdd, EventUpdate etc)
    Last edited by Arohan; Apr 22, 2014 at 8:46 AM. Reason: Typo error
  6. #6
    You can use the following override to copy event during drag drop operation if ctrl key is pressed
    Ext.calendar.view.AbstractCalendar.override({
                onEventDrop: function (rec, dt) {
                    var copy = Ext.EventObject.ctrlKey,
                        store = this.store;
    
    
                    if (Ext.calendar.util.Date.compare(rec.data[Ext.calendar.data.EventMappings.StartDate.name], dt) === 0 && !copy) {
                        // no changes
                        return;
                    }
                    if (copy) {
                        rec = rec.copy();
                    }
    
    
                    var diff = dt.getTime() - rec.data[Ext.calendar.data.EventMappings.StartDate.name].getTime();
                    rec.set(Ext.calendar.data.EventMappings.StartDate.name, dt);
                    rec.set(Ext.calendar.data.EventMappings.EndDate.name, Ext.calendar.util.Date.add(rec.data[Ext.calendar.data.EventMappings.EndDate.name], { millis: diff }));
    
    
                    if (copy) {
                        store.add(rec);
                        this.up('calendarpanel').fireEvent('eventadd', this, rec);
                    }
                    else {
                        this.fireEvent('eventmove', this, rec);
                    }
                }
            });
  7. #7
    Thanks a lot Vladimir. Its working perfect. Please mark this thread as Closed

Similar Threads

  1. [CLOSED] CalendarPanel: customizing the event slot.
    By supera in forum 2.x Legacy Premium Help
    Replies: 4
    Last Post: Apr 04, 2013, 4:40 AM
  2. [CLOSED] CalendarPanel: DayView Event Issue
    By csssi_coolite in forum 1.x Legacy Premium Help
    Replies: 3
    Last Post: Jun 18, 2011, 2:03 AM
  3. Replies: 2
    Last Post: Jun 16, 2011, 1:41 AM
  4. [CLOSED] Calendarpanel problem, could not focus the event correct.
    By csssi_coolite in forum 1.x Legacy Premium Help
    Replies: 3
    Last Post: Apr 24, 2011, 12:54 PM
  5. [CLOSED] CalendarPanel : event color
    By ddslogistics in forum 1.x Legacy Premium Help
    Replies: 1
    Last Post: Mar 04, 2011, 4:31 PM

Posting Permissions