You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: blazor/datagrid/custom-toolbar.md
+5-13Lines changed: 5 additions & 13 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -12,8 +12,6 @@ The custom toolbar in the Syncfusion<sup style="font-size:70%">®</sup> Blazo
12
12
13
13
This is implemented by using the `Template` property, which provides extensive customization options for the toolbar. Define a custom template for the toolbar and handle toolbar item actions in the **OnClick** event.
14
14
15
-
The following example demonstrates how to render a custom toolbar using `Template`:
16
-
17
15
{% tabs %}
18
16
{% highlight razor tabtitle="Index.razor" %}
19
17
@using Syncfusion.Blazor.Grids
@@ -113,16 +111,14 @@ The following example demonstrates how to render a custom toolbar using `Templat
Rendering an image with text in the custom toolbar of the Syncfusion<supstyle="font-size:70%">®</sup> Blazor DataGrid helps provide context and improves visual clarity for actions.
121
119
122
120
To render an image with text in the custom toolbar, use the `Template` in [SfToolbar](https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.Navigations.SfToolbar.html).
123
121
124
-
The following example demonstrates how to render images and text in the Grid toolbar using `Template`:
125
-
126
122
{% tabs %}
127
123
{% highlight razor tabtitle="Index.razor" %}
128
124
@using Syncfusion.Blazor.Grids
@@ -224,9 +220,9 @@ The following example demonstrates how to render images and text in the Grid too
224
220
225
221
## Render SfDropDownList in Custom Toolbar
226
222
227
-
Rendering an **SfDropDownList** in the custom toolbar of the Syncfusion<supstyle="font-size:70%">®</sup> Blazor DataGrid extends toolbar functionality and enables actions based on user selection.
223
+
Rendering an [SfDropdownList](https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.DropDowns.SfDropDownList-2.html) in the custom toolbar of the Syncfusion<supstyle="font-size:70%">®</sup> Blazor DataGrid extends toolbar functionality and enables actions based on user selection.
228
224
229
-
This is achieved by using the `Template`. The example below shows how to render the **SfDropDownList** in the custom toolbar, where the toolbar template binds the [ValueChanged](https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.DropDowns.SfDropDownList-2.html#Syncfusion_Blazor_DropDowns_SfDropDownList_2_ValueChanged) event to the **OnChange** method.
225
+
This is achieved by using the `Template`. The example below shows how to render the `SfDropDownList` in the custom toolbar, where the toolbar template binds the [ValueChanged](https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.DropDowns.SfDropDownList-2.html#Syncfusion_Blazor_DropDowns_SfDropDownList_2_ValueChanged) event to the **OnChange** method.
230
226
231
227
In the **OnChange** method, the selected item text determines the action. For example, if **Update** is chosen, the [EndEditAsync](https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.Grids.SfGrid-1.html#Syncfusion_Blazor_Grids_SfGrid_1_EndEditAsync) method exits edit mode. If **Edit** is selected, the selected record is passed to [StartEditAsync](https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.Grids.SfGrid-1.html#Syncfusion_Blazor_Grids_SfGrid_1_StartEditAsync) to start editing dynamically. Similarly, if **Delete** is chosen, the selected record is passed to [DeleteRecordAsync](https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.Grids.SfGrid-1.html#Syncfusion_Blazor_Grids_SfGrid_1_DeleteRecordAsync) to remove it from the Grid.
232
228
@@ -361,8 +357,6 @@ This is implemented by using the `Template` property of the [Toolbar](https://bl
361
357
362
358
In the **OnSearch** method, the selected value from `SfAutoComplete` is used as the search keyword. The Grid’s [SearchAsync](https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.Grids.SfGrid-1.html#Syncfusion_Blazor_Grids_SfGrid_1_SearchAsync_System_String_) method filters records that match the keyword across all searchable columns.
363
359
364
-
The following example shows how to render `SfAutoComplete` inside the Grid toolbar and use it to perform search operations:
365
-
366
360
{% tabs %}
367
361
{% highlight razor tabtitle="Index.razor" %}
368
362
@@ -470,16 +464,14 @@ The following example shows how to render `SfAutoComplete` inside the Grid toolb
## Render a component or element using the Toolbar Template
476
470
477
471
Rendering a component or element by using the toolbar template in the Syncfusion<supstyle="font-size:70%">®</sup> Blazor DataGrid extends the toolbar with custom components such as buttons, dropdowns, input fields, icons, or other UI elements. Event handlers can be bound within the template to enable actions for the added components.
478
472
479
473
To render custom components within the toolbar, use the `Template` directive. For example, include an [SfButton](https://help.syncfusion.com/cr/blazor/syncfusion.blazor.buttons.sfbutton.html) and perform specific Grid actions based on button clicks. When the **ExcelExport** button is clicked, [ExportToExcelAsync](https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.Grids.SfGrid-1.html#Syncfusion_Blazor_Grids_SfGrid_1_ExportToExcelAsync_Syncfusion_Blazor_Grids_ExcelExportProperties_System_Nullable_System_Boolean__System_Object_System_Nullable_System_Boolean__) exports the Grid to Excel. When the **PdfExport** button is clicked, [ExportToPdfAsync](https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.Grids.SfGrid-1.html#Syncfusion_Blazor_Grids_SfGrid_1_ExportToPdfAsync_Syncfusion_Blazor_Grids_PdfExportProperties_System_Nullable_System_Boolean__System_Object_System_Nullable_System_Boolean__) exports the Grid to PDF. Likewise, when the Print button is clicked, [PrintAsync](https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.Grids.SfGrid-1.html#Syncfusion_Blazor_Grids_SfGrid_1_PrintAsync) is triggered to print the Grid.
480
474
481
-
The following example demonstrates how to render an **SfButton** in the toolbar using `Template` and perform Grid actions based on the corresponding button click:
482
-
483
475
{% tabs %}
484
476
{% highlight razor tabtitle="Index.razor" %}
485
477
@using Syncfusion.Blazor.Grids
@@ -576,4 +568,4 @@ The following example demonstrates how to render an **SfButton** in the toolbar
Copy file name to clipboardExpand all lines: blazor/datagrid/tool-bar.md
+3-9Lines changed: 3 additions & 9 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -15,8 +15,6 @@ The toolbar can be configured with built-in toolbar items or custom items using
15
15
- An array of strings for built-in items
16
16
- An array of [ItemModel](https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.Navigations.ItemModel.html#Syncfusion_Blazor_Navigations_ItemModel__ctor) objects for custom items (text, icon, id, tooltip)
17
17
18
-
The following example demonstrates how to configure toolbar items in the Grid:
19
-
20
18
{% tabs %}
21
19
{% highlight razor tabtitle="Index.razor" %}
22
20
@using Syncfusion.Blazor.Grids
@@ -90,9 +88,7 @@ The following example demonstrates how to configure toolbar items in the Grid:
90
88
91
89
Enable or disable toolbar items dynamically to control which actions are available based on application logic or user interactions.
92
90
93
-
Toolbar items in the Syncfusion<supstyle="font-size:70%">®</sup> Blazor DataGrid can be enabled or disabled dynamically using the [EnableToolbarItemsAsync](https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.Grids.SfGrid-1.html#Syncfusion_Blazor_Grids_SfGrid_1_EnableToolbarItemsAsync_System_Collections_Generic_List_System_String__System_Boolean_) method. This provides programmatic control over the availability of specific items by their IDs. For built-in toolbar items specified with strings, the Grid generates IDs (for example, Grid_Add, Grid_Edit). For custom items created with ItemModel, set the Id property explicitly and use it when enabling or disabling items.
94
-
95
-
In the following example, the [Blazor Toggle Switch](https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.Buttons.SfSwitch-1.html) toggles toolbar item availability via a Grid method. When the switch is toggled, the [ValueChange](https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.Buttons.SfSwitch-1.html#Syncfusion_Blazor_Buttons_SfSwitch_1_ValueChange) event executes and updates the toolbar items. Verify that the IDs passed match the toolbar item IDs generated for the Grid in the target version.
91
+
Toolbar items in the Syncfusion<supstyle="font-size:70%">®</sup> Blazor DataGrid can be enabled or disabled dynamically using the [EnableToolbarItemsAsync](https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.Grids.SfGrid-1.html#Syncfusion_Blazor_Grids_SfGrid_1_EnableToolbarItemsAsync_System_Collections_Generic_List_System_String__System_Boolean_) method. This provides programmatic control over the availability of specific items by their IDs. For built-in toolbar items specified with strings, the Grid generates IDs (for example, **Grid_Add, Grid_Edit**). For custom items created with ItemModel, set the Id property explicitly and use it when enabling or disabling items.
96
92
97
93
{% tabs %}
98
94
{% highlight razor tabtitle="Index.razor" %}
@@ -134,7 +130,7 @@ In the following example, the [Blazor Toggle Switch](https://help.syncfusion.com
134
130
}
135
131
136
132
}
137
-
133
+
138
134
public async Task ToolbarClickHandler(Syncfusion.Blazor.Navigations.ClickEventArgs args)
139
135
{
140
136
if (args.Item.Text == "Expand")
@@ -211,8 +207,6 @@ Enable or disable toolbar items based on the selected row so that actions are av
211
207
212
208
Use the [RowSelecting](https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.Grids.GridEvents-1.html#Syncfusion_Blazor_Grids_GridEvents_1_RowSelecting) event with the [EnableToolbarItemsAsync](https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.Grids.SfGrid-1.html#Syncfusion_Blazor_Grids_SfGrid_1_EnableToolbarItemsAsync_System_Collections_Generic_List_System_String__System_Boolean_) method to toggle specific items by id during selection. For built-in items, refer to the generated toolbar item IDs (for example, Grid_Add, Grid_Edit, Grid_Delete). For custom items, use the ItemModel Id value. Ensure that the IDs used match the rendered toolbar item IDs in the target version.
213
209
214
-
The following code example demonstrates enabling or disabling toolbar items based on the selected row data:
215
-
216
210
{% tabs %}
217
211
{% highlight razor tabtitle="Index.razor" %}
218
212
@@ -405,4 +399,4 @@ The following example demonstrates changing the background color of the `Add`, `
405
399
406
400
N> Refer to the [Blazor DataGrid](https://www.syncfusion.com/blazor-components/blazor-datagrid) feature tour for a broad overview. Explore the [Blazor DataGrid example](https://blazor.syncfusion.com/demos/datagrid/overview?theme=bootstrap5) to understand data presentation and manipulation.
407
401
408
-
N> Styling tips: when using CSS isolation, place styles in the component’s .razor.css file. To target inner elements from isolated CSS, use the ::deep selector where appropriate. Consider additional state styles (hover, active, focus-visible, disabled) and high-contrast themes to improve accessibility.
402
+
N> Styling tips: when using CSS isolation, place styles in the component’s **.razor.css** file. To target inner elements from isolated CSS, use the **::deep** selector where appropriate. Consider additional state styles (hover, active, focus-visible, disabled) and high-contrast themes to improve accessibility.
Copy file name to clipboardExpand all lines: blazor/datagrid/toolbar-items.md
+7-15Lines changed: 7 additions & 15 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -33,8 +33,6 @@ Add them by defining the [Toolbar](https://help.syncfusion.com/cr/blazor/Syncfus
33
33
34
34
N> Built-in item IDs are typically prefixed with the grid ID (for example, Grid_add). Use these IDs in event handlers for robust detection.
35
35
36
-
The following example demonstrates how to enable built-in toolbar items such as `Print` and `Search` in the DataGrid:
37
-
38
36
{% tabs %}
39
37
{% highlight razor tabtitle="Index.razor" %}
40
38
@using Syncfusion.Blazor.Grids
@@ -111,7 +109,7 @@ The following example demonstrates how to enable built-in toolbar items such as
111
109
112
110
Showing only icons in the built-in toolbar items allows a compact toolbar layout.
113
111
114
-
To display only icons, hide the text portion of the buttons using CSS. Consider accessibility: keep an accessible name by providing TooltipText or aria-labels so screen readers still announce the action.
112
+
To show only icons, hide the text part of the buttons using CSS. For accessibility, provide an accessible name by using **TooltipText** or **aria-label** so screen readers can announce the action correctly.
115
113
116
114
{% tabs %}
117
115
{% highlight razor tabtitle="Index.razor" %}
@@ -195,9 +193,7 @@ To display only icons, hide the text portion of the buttons using CSS. Consider
195
193
196
194
The Syncfusion<supstyle="font-size:70%">®</sup> Blazor DataGrid allows customizing built-in toolbar items, including disabling default actions and executing custom logic when a button is clicked.
197
195
198
-
Handle the [OnToolbarClick](https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.Grids.GridEvents-1.html#Syncfusion_Blazor_Grids_GridEvents_1_OnToolbarClick) event to intercept actions. Prefer checking args.Item.Id for reliability (IDs are stable and not affected by localization), although Text is also available.
199
-
200
-
The following example demonstrates disabling and canceling the `Add` button functionality and showing a custom message when the `Add` button is clicked:
196
+
Handle the [OnToolbarClick](https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.Grids.GridEvents-1.html#Syncfusion_Blazor_Grids_GridEvents_1_OnToolbarClick) event to intercept actions. Prefer checking **args.Item.Id** for reliability (IDs are stable and not affected by localization), although Text is also available.
201
197
202
198
{% tabs %}
203
199
{% highlight razor tabtitle="Index.razor" %}
@@ -289,7 +285,7 @@ Adding custom toolbar items to the Syncfusion<sup style="font-size:70%">®</s
289
285
290
286
Define custom items by setting the [Toolbar](https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.Grids.SfGrid-1.html#Syncfusion_Blazor_Grids_SfGrid_1_Toolbar) property to a collection of [ItemModel](https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.Navigations.ItemModel.html#Syncfusion_Blazor_Navigations_ItemModel__ctor) objects, and handle actions in the [OnToolbarClick](https://blazor.syncfusion.com/documentation/datagrid/events#ontoolbarclick) event.
291
287
292
-
By default, custom toolbar items are positioned on the `left` side. Change the position using the [Align](https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.Navigations.ItemModel.html#Syncfusion_Blazor_Navigations_ItemModel_Align) property of ItemModel. The following example positions **Collapse All** on the `right`:
288
+
By default, custom toolbar items are positioned on the **left** side. Change the position using the [Align](https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.Navigations.ItemModel.html#Syncfusion_Blazor_Navigations_ItemModel_Align) property of ItemModel.
293
289
294
290
{% tabs %}
295
291
{% highlight razor tabtitle="Index.razor" %}
@@ -389,8 +385,6 @@ Combining built-in and custom items provides flexibility to create a toolbar wit
389
385
390
386
Define the [Toolbar](https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.Grids.SfGrid-1.html#Syncfusion_Blazor_Grids_SfGrid_1_Toolbar) property as an array that contains both built-in item names (strings) and custom items (objects with properties such as [Text](https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.Navigations.ToolbarItem.html#Syncfusion_Blazor_Navigations_ToolbarItem_Text), [PrefixIcon](https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.Navigations.ToolbarItem.html#Syncfusion_Blazor_Navigations_ToolbarItem_PrefixIcon), and [Id](https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.Navigations.ToolbarItem.html#Syncfusion_Blazor_Navigations_ToolbarItem_Id)).
391
387
392
-
The following example demonstrates how to use both built-in and custom toolbar items in the DataGrid. Built-in items include **Add**, **Edit**, **Delete**, **Update**, and **Cancel**, and the custom item Click triggers a custom message:
393
-
394
388
{% tabs %}
395
389
{% highlight razor tabtitle="Index.razor" %}
396
390
@using Syncfusion.Blazor.Grids
@@ -484,8 +478,6 @@ Customizing the position of a custom toolbar item modifies its default placement
484
478
485
479
By default, custom toolbar items are aligned on the left. Modify the position by setting the [Align](https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.Navigations.ItemModel.html#Syncfusion_Blazor_Navigations_ItemModel_Align) property of the [ItemModel](https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.Navigations.ItemModel.html#Syncfusion_Blazor_Navigations_ItemModel__ctor).
486
480
487
-
In the following sample, the `Collapse All` item is positioned on the **right**, the `Expand All` item on the **left**, and the `Search` item in the **center**:
488
-
489
481
{% tabs %}
490
482
{% highlight razor tabtitle="Index.razor" %}
491
483
@using Syncfusion.Blazor.Grids
@@ -581,12 +573,10 @@ When creating custom toolbar items using the same text as default items (such as
581
573
582
574
To avoid this behavior and ensure proper functionality:
583
575
584
-
- Assign a unique `Id` to each custom toolbar item to distinguish it from default items.
585
-
- Use the `Text`, `PrefixIcon`, and `TooltipText` properties of [ItemModel](https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.Navigations.ItemModel.html#Syncfusion_Blazor_Navigations_ItemModel__ctor) to define appearance.
576
+
- Assign a unique **Id** to each custom toolbar item to distinguish it from default items.
577
+
- Use the **Text**, **PrefixIcon**, and **TooltipText** properties of [ItemModel](https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.Navigations.ItemModel.html#Syncfusion_Blazor_Navigations_ItemModel__ctor) to define appearance.
586
578
- Handle actions in `OnToolbarClick` using the Id (or Text, if necessary).
587
579
588
-
The following sample shows custom toolbar items with text matching default items. These may be disabled when `GridEditSettings` is present because they are considered default items without unique IDs.
589
-
590
580
{% tabs %}
591
581
{% highlight razor tabtitle="Index.razor" %}
592
582
@using Syncfusion.Blazor.Grids
@@ -684,8 +674,10 @@ Customize a toolbar item’s tooltip text by adding items externally and setting
0 commit comments