Page 1 of 1

[REACT] SetDuration when creating an event

Posted: Mon May 09, 2022 3:09 pm
by yannis

Hi !
With my team we would like to edit the event duration based on certain user choices.
To make it simple, the user selects a type of appointment which automatically fills in the startTime and endTime fields of the eventEditor (So we want to update the duration of the event when selecting the "type" field).

We tried with the setDuration but it causes the event to be recorded (which does not succeed)

Here is our code for the comboField which should update the duration of the event

Thanks for help,

	typeField: {
				required: true,
				editable: true,
				weight: 2,
				type: "combo",
				store: typesStore,
				label: "type",
				valueField: "scheduleStatus",
				displayField: "label",
				name: "status",
				value: 1,
				clearable: true,
				onSelect(event: any) {
					if (event.record && event.userAction) {
						const eventEditor = this.up()
						eventEditor.eventEditFeature.eventRecord.setDuration(0.5, "h")
					}
				},
	}

Re: [REACT] SetDuration when creating an event

Posted: Tue May 10, 2022 3:13 pm
by saki

It is not fully clear to me what

it causes the event to be recorded (which does not succeed)

actually fails here. I was trying to update the underlying record of the editor by calling setDuration and the only problem I run into was that editor fields were not updated. This is easily remedied by setting autoUpdateFields:true on the eventEdit feature.

If there is another issue you are facing, post please a runnable showcase so that we can sort it out.

Note: There is a ticket to make the property public https://github.com/bryntum/support/issues/4588