Page 1 of 1

[VUE] Dynamic load data from server

Posted: Wed Apr 07, 2021 2:22 pm
by MichaelZhu

Hi,

I'd like to load data from server when selected date changed.
Bellow is the code snip:

                <scheduler-pro
                  ref="scheduler"
                  :startDate="startDate"
                  :endDate="endDate"
                  :config="productionPlanConfig"
                  :resource-time-ranges-feature="true"
                  :auto-adjust-time-axis="true"
                  :zoom-on-mouse-wheel="true"
                  :zoom-on-time-axis-double-click="true"
                  event-layout="pack"
                  :height="height"
                />
  watch: {
    myDate(newVal) {
      this.startDate = this.$moment(newVal)
        .startOf("month")
        .toDate();
      this.endDate = this.$moment(newVal)
        .endOf("month")
        .add(1, "days")
        .toDate();

  const schedulerInstance = this.$refs.scheduler.schedulerInstance;
  // schedulerInstance.suspendRefresh();

  schedulerInstance.project.load({ date: this.$moment(newVal).format('yyyy-MM-DDTHH:mm:ss') }).then(() => {
    console.log(schedulerInstance);
    schedulerInstance.timeAxis.startDate = this.startDate;
    schedulerInstance.timeAxis.endDate = this.endDate;
    // schedulerInstance.resumeRefresh(false);
  });
}
  }

The scheduler does render the UI when call the load() method first time but rendered after call the load() second time.

First time

1.png
1.png (168.59 KiB) Viewed 413 times

Second time

2.png
2.png (230.39 KiB) Viewed 413 times

Regards


Re: [VUE] Dynamic load data from server

Posted: Thu Apr 08, 2021 9:19 am
by mats

Instead of

schedulerInstance.timeAxis.startDate = this.startDate;
    schedulerInstance.timeAxis.endDate = this.endDate;

Please use https://bryntum.com/docs/scheduler/#Scheduler/view/Scheduler#function-setTimeSpan

Does this fix it?


Re: [VUE] Dynamic load data from server

Posted: Thu Apr 08, 2021 9:39 am
by MichaelZhu

Hi Mats,

It is OK now if there're events load from server first time. But still not work when retreved an empty array from server.
Step1 load from server and got empty events
Step2 load from server, got events but the events not render
Step3 load from server, got events and rendered

Regards


Re: [VUE] Dynamic load data from server

Posted: Thu Apr 08, 2021 12:11 pm
by mats

Could you please provide a simple test case? (ZIP up and upload in this thread)