未加星标

Master Time with the Kendo UI for Angular Scheduler

字体大小 | |
[前端(javascript) 所属分类 前端(javascript) | 发布者 店小二03 | 时间 2018 | 作者 红领巾 ] 0人收藏点击收藏

The Scheduler for Kendo UI for Angular has arrived. Check out everything you can do with this new component today, and let us know where you'd like to see it go next.

I'm beyond excited to be able to type these words: TheKendo UI for AngularScheduler component is finally here! I know that many of you have been waiting for this component for a while and the day has come where you can start building in scheduling abilities in to your Angular applications!

There's plenty to talk about with this component so I wanted to provide an introduction to the Scheduler that will give you an idea of exactly what is possible with the component and what we're looking to add to it in the future.

Let's jump in right away!


Master Time with the Kendo UI for Angular Scheduler
Basic Data Binding

There are a couple of ways you can bind to the Scheduler, but at the core of everything is the SchedulerEvent class. While the Scheduler component deals with dates pretty easily, we do need more information around events than simply providing an array of javascript dates. This is why we created the SchedulerEvent class. Let's discuss this class just a little bit before doing more on binding.

The SchedulerEvent Class

TheSchedulerEvent Class is a helper class that allows us to interface with something as advanced as the Scheduler. SchedulerEvent is simply set of fields designed to make sure the Scheduler operates correctly.

Note: For those of you that have used theSchedulerfrom our jQuery component library , this will seem pretty familiar as we also had a class ready for event scheduling there.

I recommend looking over thedocumentationfor more details, but here's a quick rundown of the fields available:

Required end isAllDay start title Not-required description endTimezone id recurrenceExceptions recurrenceId recurrenceRule startTimezone

The names of the fields kind of give away what their purpose is, but its fairly easy to see just how to build this out for yourself when you follow along the SchedulerEvent API docs .

In a future iteration of the Scheduler we will have an option for mapping model fields within the component's configuration, but with this initial version you will have to set up your events in a more manual way.

As a quick helpful tip, if you have an existing model that you would like to use to bind to the Scheduler you can simply map from your model to an array of SchedulerEvents like this sample taken from our documentation :

import { SchedulerEvent } from '@progress/kendo-angular-scheduler'; const events = model.map(dataItem => ( <SchedulerEvent> { id: dataItem.TaskID, start: dataItem.Start, end: dataItem.End, isAllDay: dataItem.IsAllDay, title: dataItem.Title, // Optional fields startTimezone: dataItem.startTimezone, endTimezone: dataItem.endTimezone, description: dataItem.Description, recurrenceRule: dataItem.RecurrenceRule, recurrenceId: dataItem.RecurrenceID, recurrenceException: dataItem.RecurrenceException } )); Binding

Once we're familiar with how to set up individual events, let's go ahead and actually bind to the Scheduler! There are two ways right now, using the built-in directive ormanual binding.

Built-in Directive import { Component } from '@angular/core'; import { SchedulerEvent } from '@progress/kendo-angular-scheduler'; @Component({ selector: 'my-app', template: ` <kendo-scheduler [kendoSchedulerBinding]="events [selectedDate]="selectedDate" style="height: 600px;"> <kendo-scheduler-week-view startTime="07:00"> </kendo-scheduler-week-view> </kendo-scheduler> ` }) export class AppComponent { public selectedDate: Date = new Date('2018-10-22'); public events: SchedulerEvent[] = [{ id: 1, title: 'Breakfast', start: new Date('2018-10-22T09:00:00'), end: new Date('2018-10-22T09:30:00'), recurrenceRule: 'FREQ=DAILY;COUNT=5;' }]; } This is pretty easy to set up. Once we define our array of SchedulerEvent objects, we then use the [kendoSchedulerBinding] attribute and pass in our events to this property. This approach will filter the events that are out of range for the current view, and expands the recurring series in-memory. Manual Binding import { Component } from '@angular/core'; import { SchedulerEvent } from '@progress/kendo-angular-scheduler'; @Component({ selector: 'my-app', template: ` <kendo-scheduler [events]="events [selectedDate]="selectedDate" style="height: 600px;"> <kendo-scheduler-week-view startTime="07:00"> </kendo-scheduler-week-view> </kendo-scheduler> ` }) export class AppComponent { public selectedDate: Date = new Date('2018-10-22'); public events: SchedulerEvent[] = [{ id: 1, title: 'Breakfast', start: new Date('2018-10-22T09:00:00'), end: new Date('2018-10-22T09:30:00'), }]; } With manual binding we instead use the [events] attribute when binding to our events. As mentioned, you have to do a little bit more leg work here and the built-in recurrence engine will not be used, but it gives you some flexibility to make sure the Scheduler fits into your application. Editing

Currently editing is done using the reactive directive, kendoSchedulerReactiveEditing . This is a Reactive Model-Driven Form , which is the only supported way to edit these items as of writing this blog post (November 2018). However, in the future we will also add in support for Template-Driven Forms . Editing is also handled by a user double-clicking on an event, as dragging/resizing an event is not available (yet). By the way, this is one of the first items we are looking to address over the next couple of weeks, so it will be added as soon as it's available in a future version of the component!


Master Time with the Kendo UI for Angular Scheduler

As you can see, we can edit both single events and the rules we want to set up around recurrence, which is great to see as an out-of-the-box set of features.

I recommend checking out the automatic editing documentation article to see exactly how to enable editing in your own implementation of the Scheduler.

Views

As a part of its initial release, the Angular Scheduler supports the following views.

Day and Week View
Master Time with the Kendo UI for Angular Scheduler
Month View
Master Time with the Kendo UI for Angular Scheduler
Timeline View

本文前端(javascript)相关术语:javascript是什么意思 javascript下载 javascript权威指南 javascript基础教程 javascript 正则表达式 javascript设计模式 javascript高级程序设计 精通javascript javascript教程

代码区博客精选文章
分页:12
转载请注明
本文标题:Master Time with the Kendo UI for Angular Scheduler
本站链接:https://www.codesec.net/view/610665.html


1.凡CodeSecTeam转载的文章,均出自其它媒体或其他官网介绍,目的在于传递更多的信息,并不代表本站赞同其观点和其真实性负责;
2.转载的文章仅代表原创作者观点,与本站无关。其原创性以及文中陈述文字和内容未经本站证实,本站对该文以及其中全部或者部分内容、文字的真实性、完整性、及时性,不作出任何保证或承若;
3.如本站转载稿涉及版权等问题,请作者及时联系本站,我们会及时处理。
登录后可拥有收藏文章、关注作者等权限...
技术大类 技术大类 | 前端(javascript) | 评论(0) | 阅读(79)