I'm trying to set my schedule working hours on different days/dates
The working hours will be coming from the database.
What I currently did was based from this link, but it does not work because the groupIndex parameter of schedulerObj.setWorkHours method is statically defined.
https://stackblitz.com/edit/angular-ysiqa8-k1dczm?file=app.component.ts
Here's the start and end time that I should implement in the scheduler.
The scheduler is group by name of persons
Here's my actual code, I am calling this method on dataBinding event of scheduler
|
public workHours1: any = [
{ startHour: '07:00', endHour: '16:00' }, // for Sunday { startHour: '06:00', endHour: '17:00', groupIndex: 0 }, // for Monday { startHour: '05:00', endHour: '18:00', groupIndex: 1 }, // for Tuesday { startHour: '06:30', endHour: '19:00', groupIndex: 2 }, // for Wednesday { startHour: '05:30', endHour: '20:00', groupIndex: 0 }, // for Thursday { startHour: '10:00', endHour: '21:00', groupIndex: 1 }, // for Friday { startHour: '13:00', endHour: '22:00' }, // for Saturday ]; public workHours2: any = [ { startHour: '08:00', endHour: '17:00' }, // for Sunday { startHour: '09:00', endHour: '18:00', groupIndex: 2 }, // for Monday { startHour: '10:00', endHour: '19:00', groupIndex: 0 }, // for Tuesday { startHour: '11:00', endHour: '20:00', groupIndex: 1 }, // for Wednesday { startHour: '12:00', endHour: '21:00', groupIndex: 2 }, // for Thursday { startHour: '13:00', endHour: '22:00', groupIndex: 0 }, // for Friday { startHour: '14:00', endHour: '23:00' }, // for Saturday ]; public workHours3: any = [ { startHour: '08:30', endHour: '17:00' }, // for Sunday { startHour: '09:00', endHour: '16:00', groupIndex: 1 }, // for Monday { startHour: '10:30', endHour: '19:00', groupIndex: 2 }, // for Tuesday { startHour: '11:00', endHour: '18:00', groupIndex: 0 }, // for Wednesday { startHour: '12:00', endHour: '20:00', groupIndex: 1 }, // for Thursday { startHour: '13:00', endHour: '21:00', groupIndex: 2 }, // for Friday { startHour: '10:00', endHour: '18:00' }, // for Saturday ]; onDataBound(args): void {
if (this.islayoutChanged) { var renderedDates = this.scheduleObj.activeView.getRenderDates(); this.scheduleObj.resetWorkHours(); for (var i = 0; i < renderedDates.length; i++) { var dayIndex = renderedDates[i].getDay(); if (dayIndex !== 0 && dayIndex !== 6) { this.scheduleObj.setWorkHours( [renderedDates[i]], this.workHours1[dayIndex].startHour, this.workHours1[dayIndex].endHour, this.workHours1[dayIndex].groupIndex ); this.scheduleObj.setWorkHours( [renderedDates[i]], this.workHours2[dayIndex].startHour, this.workHours2[dayIndex].endHour, this.workHours2[dayIndex].groupIndex ); this.scheduleObj.setWorkHours( [renderedDates[i]], this.workHours3[dayIndex].startHour, this.workHours3[dayIndex].endHour, this.workHours3[dayIndex].groupIndex ); } } } } |
how can I get the groupindex dynamically? and its length?
I tried this:
this.locationWorkhours contains this:
this.clinicianLength is the number of doctors, thus, the resource length