ModelFields with nested json object for scheduler

2 Answers 79 Views
Scheduler
Thomas
Top achievements
Rank 1
Iron
Thomas asked on 05 Jun 2022, 07:19 AM

Hi,
i have an nested (start_end) json array for the scheduler. The structure of the json array looks like that:
[{
          TaskID: 0,
          Subject: 'Breakfast with Tom',
          start_end: [{
            start: new Date('2019-08-10T05:30:00.000Z'),
            end: new Date('2019-08-10T06:00:00.000Z')
          }]
        }]

How can i map with the ModelFields to get correct json data for the scheduler?

 modelFields: {
        id: 'TaskID',
        title: 'Subject',
        start: ???????,
        end:  ???????,
      },

Best regards gongl

2 Answers, 1 is accepted

Sort by
0
Petar
Telerik team
answered on 06 Jun 2022, 11:13 AM

Hi, Thomas.

Based on the shared data array, the approach I can suggest to you is demonstrated in this StackBlitz example.

In the above project, we have the following computed property definition:

computedData() {
  return this.data.map((el) => ({ ...el, Dates: el.Dates[0] }));
}

I hope the suggested approach will help you achieve what you need in your application. 

Regards,
Petar
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.

0
Thomas
Top achievements
Rank 1
Iron
answered on 07 Jun 2022, 05:05 PM

Exactly what I need!

Thanks!!!!!!

Regards 

Thomas

Petar
Telerik team
commented on 08 Jun 2022, 06:07 AM

You are welcome, Thomas! 

I am glad to hear that the suggested solution has helped you.

Tags
Scheduler
Asked by
Thomas
Top achievements
Rank 1
Iron
Answers by
Petar
Telerik team
Thomas
Top achievements
Rank 1
Iron
Share this question
or