jQuery UI Widgets Forums Scheduler Angular Data refresh with event.

This topic contains 1 reply, has 2 voices, and was last updated by  Todor 4 years, 11 months ago.

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
  • Angular Data refresh with event. #106047

    andypet74
    Participant

    I have the following code:

      generateAppointments(companyID) {
       
        this.appointments = null;
        this.appointmentService.getAppointmentsByCompanyID(companyID).then(r => {
          console.log(r);
          this.appointments = r;
    
          this.events = r.map(item => {
            return {
              id: item.appointmentID,
              description: item.appointmentNotes,
              subject: item.employeeLastName + ", " + item.employeeFirstName,
              calendar: item.employeeLastName + ", " + item.employeeFirstName,
              observCat: item.customerID,
              observSub: item.observationCategoryID,
              start: new Date(item.appointmentDate),
              end: new Date(item.appointmentEndDate),
                           resizable: false,
                 draggable: false,
                 readOnly: false
            }
          });
          this.refreshdata();
          console.log(this.events);
        });
    
        
      };
    
      refreshdata() {
    
        this.source.localData = this.events;
        this.dataAdapter = new jqx.dataAdapter(this.source)
    
      }
    
     async getCustomerNameByID(customerID) {
        await this.appointmentService.getCustomerNameByCustomerID(customerID)
          .then(data => { this.customerName = data; return data; }).catch(err => console.log(err));
        
      }
      
      source: any =
        {
          dataType: "array",
          dataFields: [
            { name: 'id', type: 'string' },
            { name: 'description', type: 'string' },
            { name: 'location', type: 'string' },
            { name: 'subject', type: 'string' },
            { name: 'observCat', type: 'string' },
            { name: 'observSub', type: 'string' },
            { name: 'calendar', type: 'string' },
            { name: 'start', type: 'date' },
            { name: 'end', type: 'date' },
            { name: 'resizable', type: 'bool' },
            { name: 'draggable', type: 'bool' },
            { name: 'readOnly', type: 'bool' }
          ],
          id: 'id',
          localData: this.events
        };
      dataAdapter: any = new jqx.dataAdapter(this.source);
     
      appointmentDataFields: any =
        {
          from: "start",
          to: "end",
          id: "id",
          description: "description",
          location: "location",
          subject: "subject",
          resourceId: "calendar",
          resizable: "resizable",
          readOnly: "readOnly",
          draggable: "draggable"
        };
    
      resources: any =
        {
          colorScheme: "scheme05",
          dataField: "calendar",
          source: new jqx.dataAdapter(this.source)
        };
    
      //views: any[] =
      //  [
      //    'dayView',
      //    'weekView',
      //    'monthView'
      //  ];
      views: any[] =
        [
          {
            type: 'dayView',
            showWeekends: false
          },
          {
            type: "weekView",
            showWeekends: false,
            timeRuler: {
              scaleStartHour: 8,
              scaleEndHour: 22,
              hidden: false
            },
            workTime:
            {
              fromDayOfWeek: 1,
              toDayOfWeek: 5,
              fromHour: 8,
              toHour: 22
            }
          },
          {
            type: 'monthView',
            monthRowAutoHeight: true
          },
          'agendaView'
        ];

    my this.events has all the right data but how do I get this to the data adapter. I can’t get it to actually show on the scheduler. What I was trying to do is when a company is changed I call this generate appointments which will display the appointments for that company. How can I go about doing that?

    I was using the addAppointment() function but it looked like I needed to do a deleteAppointment() anytime I changed companies and iterate through all their appointments. There could be tens of thousands if not more appointments per company and I feel like that will be slow and that there is a better way.

    What is the best method and why does my code not produce any data on the scheduler?

    Angular Data refresh with event. #106068

    Todor
    Participant

    Hello andypet74,

    An answer is given in other topic.

    Best Regards,
    Todor

    jQWidgets Team
    https://www.jqwidgets.com

Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.