|
| 1 | +--- |
| 2 | +title: Toolbar |
| 3 | +page_title: Scheduler Toolbar |
| 4 | +description: Learn how to configure the toolbar of the Scheduler for Blazor. |
| 5 | +slug: scheduler-toolbar |
| 6 | +tags: telerik,blazor,scheduler,toolbar |
| 7 | +published: True |
| 8 | +position: 2 |
| 9 | +--- |
| 10 | + |
| 11 | +# Scheduler Toolbar |
| 12 | + |
| 13 | +The [Blazor Scheduler toolbar](https://demos.telerik.com/blazor-ui/scheduler/toolbar) can render built-in and custom tools. This article shows how to use and customize the toolbar. |
| 14 | + |
| 15 | +## Built-in Tools |
| 16 | + |
| 17 | +By default, the [Blazor Scheduler]({%slug scheduler-overview%}) displays all its built-in tools in the following order: |
| 18 | + |
| 19 | +@[template](/_contentTemplates/common/parameters-table-styles.md#table-layout) |
| 20 | + |
| 21 | +| Tool Tag | Description | |
| 22 | +| --- | --- | |
| 23 | +| `SchedulerToolBarNavigationTool` | A group of navigation buttons. They can navigate to the present day, to the previous period, and to the next period depending on the [Scheduler view]({%slug scheduler-views-overview%}). | |
| 24 | +| `SchedulerToolBarCalendarTool` | A button that shows the start and the end of the current period. Upon click, you can select a new period via a calendar popup. | |
| 25 | +| `SchedulerToolBarViewsTool` | A button group or a dropdown (depending on the screen size) with all available views. | |
| 26 | + |
| 27 | +By default, the toolbar also includes spacers (`<SchedulerToolBarSpacerTool />`). They consume the available empty space and push the rest of the tools next to one another. |
| 28 | + |
| 29 | +## Custom Tools |
| 30 | + |
| 31 | +To customize the order of the built-in tools or add a custom tool, define the `<SchedulerToolBar>` child tag in the Scheduler. To add a custom tool use the nested `<SchedulerToolBarCustomTool>` tag of the `<SchedulerToolBar>` tag. The `<SchedulerToolBarCustomTool>` is a standard Blazor `RenderFragment`. See the example below. |
| 32 | + |
| 33 | + |
| 34 | +## Toolbar Configuration |
| 35 | + |
| 36 | +Add a `<SchedulerToolBar>` tag inside `<TelerikScheduler>` to configure the toolbar, for example: |
| 37 | + |
| 38 | +* Arrange the Scheduler tools in a specific order; |
| 39 | +* Remove some of the built-in tools; |
| 40 | +* Add custom tools. |
| 41 | + |
| 42 | +>caption Customize the Scheduler toolbar |
| 43 | +
|
| 44 | +````CSHTML |
| 45 | +<TelerikScheduler Data="@Appointments" |
| 46 | + @bind-Date="@SchedulerStartDate" |
| 47 | + Height="600px"> |
| 48 | + <SchedulerToolBar> |
| 49 | + <SchedulerToolBarViewsTool /> |
| 50 | + <SchedulerToolBarNavigationTool /> |
| 51 | + <SchedulerToolBarSpacerTool /> |
| 52 | + <SchedulerToolBarCustomTool> |
| 53 | + <TelerikButton OnClick="@OnCustomToolClick">Show When the Trip to Hawaii Ends</TelerikButton> |
| 54 | + </SchedulerToolBarCustomTool> |
| 55 | + </SchedulerToolBar> |
| 56 | + <SchedulerViews> |
| 57 | + <SchedulerDayView /> |
| 58 | + <SchedulerWeekView /> |
| 59 | + <SchedulerMonthView /> |
| 60 | + </SchedulerViews> |
| 61 | +</TelerikScheduler> |
| 62 | +
|
| 63 | +@code { |
| 64 | + private DateTime SchedulerStartDate { get; set; } = DateTime.Today; |
| 65 | +
|
| 66 | + private void OnCustomToolClick() |
| 67 | + { |
| 68 | + var hawaiiTrip = Appointments.Where(x => x.Title == "Trip to Hawaii").FirstOrDefault(); |
| 69 | + if (hawaiiTrip != null) |
| 70 | + { |
| 71 | + SchedulerStartDate = hawaiiTrip.End; |
| 72 | + } |
| 73 | + } |
| 74 | +
|
| 75 | + private List<SchedulerAppointment> Appointments = new List<SchedulerAppointment>() |
| 76 | + { |
| 77 | + new SchedulerAppointment |
| 78 | + { |
| 79 | + Title = "Planning meeting", |
| 80 | + Start = DateTime.Today, |
| 81 | + End = DateTime.Today.AddHours(3) |
| 82 | + }, |
| 83 | + new SchedulerAppointment |
| 84 | + { |
| 85 | + Title = "Vet visit", |
| 86 | + Start = DateTime.Today.AddDays(2), |
| 87 | + End = DateTime.Today.AddDays(2).AddHours(1) |
| 88 | + }, |
| 89 | + new SchedulerAppointment |
| 90 | + { |
| 91 | + Title = "Trip to Hawaii", |
| 92 | + IsAllDay = true, |
| 93 | + Start = DateTime.Today.AddDays(3), |
| 94 | + End = DateTime.Today.AddDays(35) |
| 95 | + } |
| 96 | + }; |
| 97 | +
|
| 98 | + public class SchedulerAppointment |
| 99 | + { |
| 100 | + public string Title { get; set; } |
| 101 | + public DateTime Start { get; set; } |
| 102 | + public DateTime End { get; set; } |
| 103 | + public bool IsAllDay { get; set; } |
| 104 | + } |
| 105 | +} |
| 106 | +```` |
| 107 | + |
| 108 | +## See Also |
| 109 | + |
| 110 | +* [Scheduler Live Demo](https://demos.telerik.com/blazor-ui/scheduler/overview) |
| 111 | +* [Scheduler Toolbar Demo](https://demos.telerik.com/blazor-ui/scheduler/toolbar) |
0 commit comments