Discuss anything related to web development but no technical support questions


Post by Stanleyliu1006 »

Hi

I have a process when the event resize on the scheduler will show Sch.plugin.EditorWindow as the code below, I am wondering how can i easily reverse the time change when i click the cancel button in the EditorWindow (via a existing function etc). At moment only the browser refresh can restore the time change of the event. (please check details in the screenshot below).

The code on my scheduler:
            listeners : {
                aftereventresize : function(g, rec, e){
                    eventWindow = me.normalGrid.findPlugin('event_editor');
                    eventWindow.showForEvent(rec);
                },
            }
Attachments
Reverse_event_size.png
Reverse_event_size.png (39.86 KiB) Viewed 2568 times

Post by Terence »

The resize event is applying the new startdate. You can hook in before the change is applied.

https://www.bryntum.com/docs/scheduler- ... zefinalize

Listen to this event, show your dialog , and call the finalize functions.

Here is an example: https://www.bryntum.com/examples/schedu ... validation

You could call finalize(false) on save, and do further editing in the editor. You might need to adjust the loading of the record in the editor, because the unmodified record is passed. In that case you need to grab the start- and enddate from the dragContext and set the corresponding values in the editor start- and end date field.

Post by pmiklashevich »

Hello,

You can save your time info on beforeeventresize, and set it back to the record in onCancelClick. Please keep in mind it's private function. To hook into onCancelClick, you need to specify it in editorConfig something like this:
{
    ptype     : 'scheduler_editorwindow',
    editorConfig : {
        onCancelClick : function () {
            // Implement your logic here

            // Hide editor window manually 
            this.ownerCt.hide();
        }
    }
}

Pavlo Miklashevych
Sr. Frontend Developer


Post by pmiklashevich »

Actually Terence's approach looks more solid to me since you don't apply changes before you press Save in Editor. However it's up to you the way to go.

Pavlo Miklashevych
Sr. Frontend Developer


Post by Stanleyliu1006 »

Thanks for both of you guys' reply

I am considering to use onCancelClick to control the changes. So pmiklashevich can you please advise how can you pass the parameters from beforeeventresize to the record in onCancelClick? Thanks.

Kind regards
Stanley

Post by pmiklashevich »

Before resize you save record.getStartDate()/record.getEndDate() in a property of your scheduler, or in a place you think fits better for this. You can save them somewhere in your editor (but clean up them when the editor gets closed). First argument in beforeeventresize is view. So calling view.getEventEditor() you can receive your event editor. So on cancel click you call record.setStartDate(savedStartDate)/record.setEndDate(savedEndDate)

Pavlo Miklashevych
Sr. Frontend Developer


Post by Stanleyliu1006 »

Hi pmiklashevich

I think i figure it out using the code below: thanks so much
in Scheduler:
 beforeeventresize( scheduler, record, e, eOpts ){
                    scheduler.getEventEditor().startDate = record.getStartDate();
                    scheduler.getEventEditor().endDate = record.getEndDate();
                },
In Sch.plugin.EditorWindow
 onCancelClick : function () {
                    this.getRecord().setStartDate(this.startDate);
                    this.getRecord().setEndDate(this.endDate);
                    me.hide();
                }

Post Reply