Cannot read property 'scrollToDate' of undefined"

i used to get start and end date like this
constmyArray=this.$refs.scheduleObj.getCurrentViewDates();
const{0:first,length,[length-1]:last}=myArray;//gettingfirstandlastelfromarray
constobj={first,last};
this.Model.fromDate=newDate(obj.first);
this.Model.toDate=newDate(obj.last);
when i added resources i keep getting this error
Cannot read property 'scrollToDate' of undefined"

2) how to know which room i am clicking in (which room i am adding event too..)


4 Replies 1 reply marked as answer

HB Hareesh Balasubramanian Syncfusion Team April 21, 2021 03:26 AM UTC

Hi Hani,

Greetings from Syncfusion Support.
 
Q: Cannot read property 'scrollToDate of undefined' 
We have checked the reported issue but were unable to replicate the issue, so please refer to the following sample.
https://codesandbox.io/s/vue-customized-scheduler-sample-y3oss?file=/src/App.vue
 
If the issue persists still, share the issue replicating sample, replicate it in above sample or scenario in which you have used the method.

Q: how to know which room clicked.
You can get the resource details when cell click using the cellClick event and actionBegin event when add the events. The same can be referred in the above sample.
 
onCellClick: function (args) {  
      console.log(args.groupIndex); 
      var resource = this.$refs.scheduleObj.getResourceByIndex(args.groupIndex); 
    }, 
    onActionBegin: function (args) { 
      if (args.requestType == "eventCreate") { 
        console.log("Task Id:" + args.data[0].TaskId); 
        console.log("Prohect Id:" + args.data[0].ProjectId); 
      } 
    }, 

Regards,
 
Hareesh 


Marked as answer

HA Hani April 21, 2021 10:23 AM UTC

this.$refs.scheduleObj.getResourceByIndex is not a function
this error is in your sample


...
i have updated it to 

  var resource = this.$refs.scheduleObj.getResourcesByIndex(
        args.groupIndex
      );

and it works



HA Hani April 21, 2021 11:31 AM UTC

When i do left click it go to OnCellClick and everything is fine

but when i do right click and select from contextMenu to add event
it doesn't go to OnCellClick

and 
 console.log("Task Id:" + args.data[0].TaskId); 
        console.log("Prohect Id:" + args.data[0].ProjectId); 
not working neither taskId or roomId are undefined 


RV Ravikumar Venkatesan Syncfusion Team April 23, 2021 12:13 PM UTC

Hi Hani, 

Thanks for the update. 

We have validated your reported query “taskId or roomId are undefined” at our end and you can get the selected cell details with help of the getCellDetails and getResourcesByIndex method of the Schedule passing the selected target cell for the same, we have prepared a sample that can be available from the below link. 


[App.vue] 
    onContextMenuBeforeOpen: function (args) { 
      this.selectedTarget = closest(targetElement, ".e-appointment,.e-work-cells," + e-vertical-view .e-date-header-wrap .e-all-day-cells,.e-vertical-view .e-date-header-wrap .e-header-cells"); 
    }, 
    onMenuItemSelect: function (args) { 
      let scheduleObj = this.$refs.scheduleObj.ej2Instances; 
      let selectedMenuItem = args.item.id; 
      let eventObj; 
      if (this.selectedTarget.classList.contains("e-appointment")) { 
        eventObj = scheduleObj.getEventDetails(this.selectedTarget); 
      } 
      switch (selectedMenuItem) { 
        case "Add": 
        case "AddRecurrence": 
          let selectedCells = scheduleObj.getSelectedElements(); 
          let activeCellsData = scheduleObj.getCellDetails(selectedCells.length > 0 ? selectedCells : this.selectedTarget); 
          let resourceDetails = scheduleObj.getResourcesByIndex(activeCellsData.groupIndex); 
          console.log("Resource details: ", resourceDetails.groupData); 
          if (selectedMenuItem === "Add") { 
            scheduleObj.openEditor(activeCellsData, "Add"); 
          } else { 
            scheduleObj.openEditor(activeCellsData, "Add", null, 1); 
          } 
          break; 
      } 
    }, 

Kindly try the above sample and get back to us if you need any further assistance. 

Regards, 
Ravikumar Venkatesan 


Loader.
Up arrow icon