[CLOSED] CalendarPanel: override EventEditWindow

  1. #1

    [CLOSED] CalendarPanel: override EventEditWindow

    Hi, I'm trying to override EventEditWindow in CalendarPanel to remove Save and Delete buttons. I'm doing this in the following way:

    Ext.calendar.EventEditWindow.override({
        constructor: function (config) {
            var formPanelCfg = {
                xtype: 'form',
                labelWidth: 65,
                frame: false,
                bodyStyle: 'background:transparent;padding:5px 10px 10px;',
                bodyBorder: false,
                border: false,
                items: [{
                    id: 'title',
                    name: Ext.calendar.EventMappings.Title.name,
                    fieldLabel: 'Title',
                    xtype: 'textfield',
                    anchor: '100%'
                },
                {
                    xtype: 'daterangefield',
                    id: 'date-range',
                    anchor: '100%',
                    fieldLabel: 'When'
                }]
            };
    
            if (config.calendarStore) {
                this.calendarStore = config.calendarStore;
                delete config.calendarStore;
    
                formPanelCfg.items.push({
                    xtype: 'calendarpicker',
                    id: 'calendar',
                    name: 'calendar',
                    anchor: '100%',
                    store: this.calendarStore
                });
            }
    
            Ext.calendar.EventEditWindow.superclass.constructor.call(this, Ext.apply({
                titleTextAdd: 'Add Event',
                titleTextEdit: 'Edit Event',
                width: 600,
                autocreate: true,
                border: true,
                closeAction: 'hide',
                modal: false,
                resizable: false,
                buttonAlign: 'left',
                savingMessage: 'Saving changes...',
                deletingMessage: 'Deleting event...',
    
                fbar: [{
                    xtype: 'tbtext',
                    text: '<a href="#" id="tblink">Edit Details...</a>'
                },
                '->', {
                    text: 'Cancel',
                    disabled: false,
                    handler: this.onCancel,
                    scope: this
                }],
                items: formPanelCfg
            },
            config));
        },
    
        initComponent: function () {
    
            Ext.calendar.EventEditWindow.superclass.initComponent.call(this);
    
            this.formPanel = this.items.items[0];
    
            this.addEvents({
                /**
                 * @event eventcancel
                 * Fires after an event add/edit operation is canceled by the user and no store update took place
                 * @param {Ext.calendar.EventEditWindow} this
                 * @param {Ext.calendar.EventRecord} rec The new {@link Ext.calendar.EventRecord record} that was canceled
                 */
                eventcancel: true,
                /**
                 * @event editdetails
                 * Fires when the user selects the option in this window to continue editing in the detailed edit form
                 * (by default, an instance of {@link Ext.calendar.EventEditForm}. Handling code should hide this window
                 * and transfer the current event record to the appropriate instance of the detailed form by showing it
                 * and calling {@link Ext.calendar.EventEditForm#loadRecord loadRecord}.
                 * @param {Ext.calendar.EventEditWindow} this
                 * @param {Ext.calendar.EventRecord} rec The {@link Ext.calendar.EventRecord record} that is currently being edited
                 */
                editdetails: true
            });
        }
    And this does'n work. How to remove save and Delete buttons from the EventEditWindow?
    Last edited by Baidaly; Oct 21, 2013 at 3:41 PM. Reason: [CLOSED]
  2. #2
    Hi @Hlodvig,

    Unfortunately, "doesn't work" is not so informative. What happens? Is there any JavaScript error? Where do you put this override? Maybe, it is not executed, is it?
  3. #3
    Hi Daniil, sorry for missing details.

    Code above is in schedule-override.js file and I simply include it to the page

        <ext:ResourcePlaceHolder ID="ResourcePlaceHolder2" runat="server" Mode="Script" />
        <script src="/Scripts/schedule.js" type="text/javascript"></script>
        <script src="/Scripts/schedule-override.js" type="text/javascript"></script>
    schedule.js here is the file from the CalendarPanel example where CompanyX object is defined. There's no any JS error. Overriden initComponent is called, overriden constructor not. The result is... As if there were no any overrides. EventEditWindow is shown with the Save, Delete and Cancel buttons.
  4. #4
    Please try to replace
    Mode="Script"
    with
    Mode="ScriptFiles"
  5. #5
    Just tried. No any difference. As I said above overriden initComponent is called but overriden constructor (where buttons are defined) not. And it seems to me that this is a key point. Why overriden constructor is not called? How to call it?
  6. #6
    Yes, this is a key point. Ext.override() cannot override a constructor.

    What about to copy EventEditWindow.js entirely and place it after a ResourcePlaceHolder with Mode="ScriptFiles".

    Then all the changes should be taken into account.
  7. #7
    That helped. Thank you!

Similar Threads

  1. [CLOSED] Custom EventEditForm and EventEditWindow on a CalendarPanel
    By Daly_AF in forum 1.x Legacy Premium Help
    Replies: 1
    Last Post: Nov 21, 2012, 11:49 AM
  2. [CLOSED] CalendarPanel: override DayBody template
    By supera in forum 2.x Legacy Premium Help
    Replies: 4
    Last Post: May 22, 2012, 5:37 PM
  3. EventEditWindow of CalendarPanel
    By Rupesh in forum 1.x Help
    Replies: 10
    Last Post: Mar 20, 2012, 10:16 AM
  4. Calendarpanel: EventEditWindow DirectEvents
    By dotnet in forum 1.x Help
    Replies: 9
    Last Post: May 27, 2011, 10:18 AM
  5. Replies: 4
    Last Post: Apr 25, 2011, 8:35 AM

Tags for this Thread

Posting Permissions