|
| 1 | +--- |
| 2 | +title: Events |
| 3 | +page_title: DockManager - Events |
| 4 | +description: Events in the DockManager for Blazor. |
| 5 | +slug: dockmanager-events |
| 6 | +tags: telerik,blazor,dockmanager,events |
| 7 | +published: true |
| 8 | +position: 20 |
| 9 | +--- |
| 10 | + |
| 11 | +# DockManager Events |
| 12 | + |
| 13 | +This article explains the events available in the Telerik DockManager for Blazor: |
| 14 | + |
| 15 | +* [OnDock](#ondock) |
| 16 | +* [OnUndock](#ondock) |
| 17 | +* [OnPaneResize](#onpaneresize) |
| 18 | +* [State Events](#state-events) |
| 19 | +* [OnPin](#onpin) |
| 20 | +* [OnUnpin](#onunpin) |
| 21 | + |
| 22 | +## OnDock |
| 23 | + |
| 24 | +The `OnDock` event is fired when any pane is docked. |
| 25 | + |
| 26 | +The event handler receives as an argument an `DockManagerDockEventArgs` object that contains: |
| 27 | + |
| 28 | +| Property | Type | Description | |
| 29 | +|---|---|---| |
| 30 | +| `DockPosition` | `DockManagerDockPosition` | The position where the pane is being docked. The possible options are: `Left`, `Right`, `Top`, `Bottom`, `Middle`. | |
| 31 | +| `IsCancelled` | `bool` <br /> (`false`) | Set the `IsCancelled` property to `true` to cancel the event. | |
| 32 | +| `PaneId` | `string` | The Id of the floating pane that is being docked. | |
| 33 | +| `TargetPaneId` | `string` | The Id of the target pane. | |
| 34 | + |
| 35 | +## OnUndock |
| 36 | + |
| 37 | +The `OnUndock` event is fired when any pane is undocked. |
| 38 | + |
| 39 | +The event handler receives as an argument an `DockManagerUndockEventArgs` object that contains: |
| 40 | + |
| 41 | +| Property | Type | Description | |
| 42 | +|---|---|---| |
| 43 | +| `IsCancelled` | `bool` <br /> (`false`) | Set the `IsCancelled` property to `true` to cancel the event. | |
| 44 | +| `PaneId` | `string` | The Id of the floating pane that is being undocked. | |
| 45 | + |
| 46 | +## OnPaneResize |
| 47 | + |
| 48 | +The `OnPaneResize` event is fired when any pane is resized. It lets you respond to that change if needed - for example, call the `.Refresh()` method of a chart or otherwise repaint a child component in the content. You can also use it to, for example, update the saved [state](slug://dockmanager-state) for your users. |
| 49 | + |
| 50 | +The event handler receives as an argument an `DockManagerPaneResizeEventArgs` object that contains: |
| 51 | + |
| 52 | +| Property | Type | Description | |
| 53 | +|---|---|---| |
| 54 | +| `PaneId` | `string` | The Id of the pane that is being resized. | |
| 55 | +| `Size` | `string` | The new size of the resized pane. | |
| 56 | + |
| 57 | +## State Events |
| 58 | + |
| 59 | +The DockManager state lets you control through code the aspects of the DockManager the user can control in the UI - such as docking, undocking, resizing panes and etc. The DockManager provides two events related to the state: |
| 60 | + |
| 61 | +* `OnStateInit` - fires when the DockManager initializes so you can provide a stored version of the grid. |
| 62 | + |
| 63 | +* `OnStateChanged` - fires when the user performs an action so you can see what area was changed and, if needed, alter the component state. |
| 64 | + |
| 65 | +Review the [DockManager state](slug://dockmanager-state) article for more details and examples on how the grid state works and what you can do with it. |
| 66 | + |
| 67 | +## OnPin |
| 68 | + |
| 69 | +The `OnPin` event is fired when any pane is pinned. |
| 70 | + |
| 71 | +The event handler receives as an argument an `DockManagerPinEventArgs` object that contains: |
| 72 | + |
| 73 | +| Property | Type | Description | |
| 74 | +|---|---|---| |
| 75 | +| `IsCancelled` | `bool` <br /> (`false`) | Set the `IsCancelled` property to `true` to cancel the event. | |
| 76 | +| `PaneId` | `string` | The Id of the pane that is being pinned. | |
| 77 | + |
| 78 | +## OnUnpin |
| 79 | + |
| 80 | +The `OnUnpin` event is fired when any pane is unpinned. |
| 81 | + |
| 82 | +The event handler receives as an argument an `DockManagerUnpinEventArgs` object that contains: |
| 83 | + |
| 84 | +| Property | Type | Description | |
| 85 | +|---|---|---| |
| 86 | +| `IsCancelled` | `bool` <br /> (`false`) | Set the `IsCancelled` property to `true` to cancel the event. | |
| 87 | +| `PaneId` | `string` | The Id of the pane that is being unpinned. | |
| 88 | + |
| 89 | +## Example |
| 90 | + |
| 91 | +>caption DockManager with all available events. |
| 92 | +
|
| 93 | +`````RAZOR |
| 94 | +<strong>The events log is below the component.</strong> |
| 95 | +
|
| 96 | +<TelerikDockManager Height="800px" |
| 97 | + Width="90%" |
| 98 | + OnDock="@OnPaneDock" |
| 99 | + OnUndock="@OnPaneUndock" |
| 100 | + OnPin="@OnPanePin" |
| 101 | + OnPaneResize="@OnPaneResize" |
| 102 | + OnUnpin="@OnPaneUnpin"> |
| 103 | + <DockManagerPanes> |
| 104 | + <DockManagerSplitPane AllowEmpty="true"> |
| 105 | + <Panes> |
| 106 | + <DockManagerContentPane HeaderText="Task Details" |
| 107 | + Id="taskDetails"> |
| 108 | + <Content> |
| 109 | + This pane displays task details like description, assignee, and status. |
| 110 | + Task 1: Update website UI |
| 111 | + </Content> |
| 112 | + </DockManagerContentPane> |
| 113 | + <DockManagerContentPane HeaderText="Assigned To" |
| 114 | + Id="assignedTo"> |
| 115 | + <Content> |
| 116 | + This pane shows which team members are assigned to the tasks. |
| 117 | + Team Member: John Doe |
| 118 | + </Content> |
| 119 | + </DockManagerContentPane> |
| 120 | + <DockManagerContentPane HeaderText="Due Date" |
| 121 | + Id="dueDate"> |
| 122 | + <Content> |
| 123 | + This pane contains the task deadline and the progress bar. |
| 124 | + Due Date: 03/20/2025 |
| 125 | + </Content> |
| 126 | + </DockManagerContentPane> |
| 127 | + <DockManagerTabGroupPane> |
| 128 | + <Panes> |
| 129 | + <DockManagerContentPane HeaderText="Comments" |
| 130 | + Id="comments"> |
| 131 | + <Content> |
| 132 | + This pane allows team members to leave comments and feedback. |
| 133 | + Comment: "Looks good, but needs more details." |
| 134 | + </Content> |
| 135 | + </DockManagerContentPane> |
| 136 | + <DockManagerContentPane HeaderText="Attachments" |
| 137 | + Id="attachments"> |
| 138 | + <Content> |
| 139 | + This pane shows files attached to the task, such as documents and screenshots. |
| 140 | + Attachment: Project_Mockup.pdf |
| 141 | + </Content> |
| 142 | + </DockManagerContentPane> |
| 143 | + </Panes> |
| 144 | + </DockManagerTabGroupPane> |
| 145 | + </Panes> |
| 146 | + </DockManagerSplitPane> |
| 147 | + </DockManagerPanes> |
| 148 | +
|
| 149 | + <DockManagerFloatingPanes> |
| 150 | + <DockManagerSplitPane> |
| 151 | + <Panes> |
| 152 | + <DockManagerContentPane> |
| 153 | + <HeaderTemplate> |
| 154 | + <strong>Live Updates</strong> |
| 155 | + </HeaderTemplate> |
| 156 | + <Content> |
| 157 | + Displays real-time progress updates on the task. |
| 158 | + Task 1 - 50% Completed |
| 159 | + </Content> |
| 160 | + </DockManagerContentPane> |
| 161 | + </Panes> |
| 162 | + </DockManagerSplitPane> |
| 163 | + </DockManagerFloatingPanes> |
| 164 | +</TelerikDockManager> |
| 165 | +
|
| 166 | +<div class="col"> |
| 167 | + @((MarkupString)Log) |
| 168 | +</div> |
| 169 | +
|
| 170 | +@code { |
| 171 | + private string Log { get; set; } |
| 172 | +
|
| 173 | + private void OnPaneDock(DockManagerDockEventArgs args) |
| 174 | + { |
| 175 | + if (args.TargetPaneId == "taskDetails") |
| 176 | + { |
| 177 | + args.IsCancelled = true; |
| 178 | + Log += $"<br /> Task pane with ID {args.PaneId} was about to dock to task pane with ID {args.TargetPaneId}. The event is cancelled."; |
| 179 | + } |
| 180 | + else |
| 181 | + { |
| 182 | + Log += $"<br /> Task pane with ID {args.PaneId} was docked to task pane with ID {args.TargetPaneId}."; |
| 183 | + } |
| 184 | + } |
| 185 | +
|
| 186 | + private void OnPaneUndock(DockManagerUndockEventArgs args) |
| 187 | + { |
| 188 | + if (args.PaneId == "assignedTo") |
| 189 | + { |
| 190 | + args.IsCancelled = true; |
| 191 | + Log += $"<br /> Task pane with ID {args.PaneId} was about to undock. The event is cancelled."; |
| 192 | + } |
| 193 | + else |
| 194 | + { |
| 195 | + Log += $"<br /> Task pane with ID {args.PaneId} was undocked."; |
| 196 | + } |
| 197 | + } |
| 198 | +
|
| 199 | + private void OnPanePin(DockManagerPinEventArgs args) |
| 200 | + { |
| 201 | + if (args.PaneId == "dueDate") |
| 202 | + { |
| 203 | + args.IsCancelled = true; |
| 204 | + Log += $"<br /> Task pane with ID {args.PaneId} was about to pin. The event is cancelled."; |
| 205 | + } |
| 206 | + else |
| 207 | + { |
| 208 | + Log += $"<br /> Task pane with ID {args.PaneId} was pinned."; |
| 209 | + } |
| 210 | + } |
| 211 | +
|
| 212 | + private void OnPaneResize(DockManagerPaneResizeEventArgs args) |
| 213 | + { |
| 214 | + Log += $"<br /> Task pane with ID {args.PaneId} was resized. The new size is {args.Size}."; |
| 215 | + } |
| 216 | +
|
| 217 | + private void OnPaneUnpin(DockManagerUnpinEventArgs args) |
| 218 | + { |
| 219 | + if (args.PaneId == "comments") |
| 220 | + { |
| 221 | + args.IsCancelled = true; |
| 222 | + Log += $"<br /> Task pane with ID {args.PaneId} was about to unpin. The event is cancelled."; |
| 223 | + } |
| 224 | + else |
| 225 | + { |
| 226 | + Log += $"<br /> Task pane with ID {args.PaneId} was unpinned."; |
| 227 | + } |
| 228 | + } |
| 229 | +} |
| 230 | +````` |
| 231 | + |
| 232 | +## Next Steps |
| 233 | + |
| 234 | +* [Manage the Dock Manager state](slug://dockmanager-state). |
| 235 | + |
| 236 | + |
| 237 | +## See Also |
| 238 | + |
| 239 | +* [DockManager Overview](slug://dockmanager-overview) |
0 commit comments