-
Notifications
You must be signed in to change notification settings - Fork 15
997176: toolbar #7338
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
ShekAsiqSF3430
wants to merge
10
commits into
development
Choose a base branch
from
997176-toolbar
base: development
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
997176: toolbar #7338
Changes from 4 commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
8abbaa6
997176: toolbar
ShekAsiqSF3430 d557caf
997176: toolbar
ShekAsiqSF3430 4461abe
997176: toolbar
ShekAsiqSF3430 47f1b82
997176: toolbar
ShekAsiqSF3430 e097ed3
997176: toolbar
ShekAsiqSF3430 befedf3
997176: toolbar
ShekAsiqSF3430 36e149a
997176: toolbar
ShekAsiqSF3430 ef09b33
997176:toolbar
ShekAsiqSF3430 53fc7e5
997176: toolbar
ShekAsiqSF3430 2243836
997176: toolbar
ShekAsiqSF3430 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,117 @@ | ||
| --- | ||
| layout: post | ||
| title: Custom Toolbar Items in Blazor TreeGrid Component | Syncfusion | ||
| description: Learn how to create and use custom toolbar items in the Syncfusion Blazor TreeGrid, including templates, icons with text, dropdowns, and export actions. | ||
| platform: Blazor | ||
| control: TreeGrid | ||
| documentation: ug | ||
| --- | ||
|
|
||
| # Custom toolbar in Blazor TreeGrid | ||
|
ShekAsiqSF3430 marked this conversation as resolved.
Outdated
ShekAsiqSF3430 marked this conversation as resolved.
Outdated
|
||
|
|
||
| The custom toolbar in the Syncfusion<sup style="font-size:70%">®</sup> Blazor TreeGrid enables a distinctive toolbar layout, style, and behavior tailored to application requirements, delivering a personalized TreeGrid experience. | ||
|
ShekAsiqSF3430 marked this conversation as resolved.
Outdated
|
||
|
|
||
| The `ToolbarTemplate` property implements this feature and offers extensive customization options for the toolbar. | ||
|
|
||
| ## Enable/Disable Toolbar Items based on Row Selection | ||
|
|
||
| `ToolbarTemplate` feature enables rendering of custom components like [SfToolbar](https://blazor.syncfusion.com/documentation/toolbar/getting-started-webapp), which allows dynamic enabling or disabling of its toolbar items using the [Disabled](https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.Navigations.ToolbarItem.html#Syncfusion_Blazor_Navigations_ToolbarItem_Disabled) property. | ||
|
ShekAsiqSF3430 marked this conversation as resolved.
Outdated
|
||
|
|
||
| By setting the `Disabled` property of an `SfToolbar` item inside the [RowSelected](https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.TreeGrid.TreeGridEvents-1.html#Syncfusion_Blazor_TreeGrid_TreeGridEvents_1_RowSelected) event or [RowDeselected](https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.TreeGrid.TreeGridEvents-1.html#Syncfusion_Blazor_TreeGrid_TreeGridEvents_1_RowDeselected) event, you can control the custom toolbar items. | ||
|
ShekAsiqSF3430 marked this conversation as resolved.
Outdated
|
||
|
|
||
| In the following sample, the custom toolbar item **Add** is enabled when a row is selected and disabled when the row is deselected. | ||
|
|
||
|
|
||
| ```cshtml | ||
| @using Syncfusion.Blazor.Navigations | ||
| @using Syncfusion.Blazor.TreeGrid; | ||
|
|
||
|
|
||
| <SfTreeGrid @ref="TreeGrid" DataSource="@TreeGridData" IdMapping="TaskId" ParentIdMapping="ParentId" TreeColumnIndex="1"> | ||
| <TreeGridEvents RowSelected="RowSelected" RowDeselected="RowDeselected" TValue="TreeData.BusinessObject"></TreeGridEvents> | ||
| <TreeGridEditSettings AllowAdding="true" NewRowPosition="Syncfusion.Blazor.TreeGrid.RowPosition.Child"></TreeGridEditSettings> | ||
| <TreeGridTemplates> | ||
| <ToolbarTemplate> | ||
| <SfToolbar> | ||
| <ToolbarEvents Clicked = "ToolbarClickHandler"></ToolbarEvents> | ||
| <ToolbarItems> | ||
| <ToolbarItem Text="Add" Id="Add" TooltipText="Add" Disabled="@IsRowSelected"></ToolbarItem> | ||
| <ToolbarItem Text="Save" Id="Save" TooltipText="Save Data" Disabled="@EnableSave"></ToolbarItem> | ||
| </ToolbarItems> | ||
| </SfToolbar> | ||
| </ToolbarTemplate> | ||
| </TreeGridTemplates> | ||
| <TreeGridColumns> | ||
| <TreeGridColumn Field="TaskId" HeaderText="Task ID" Width="80" IsPrimaryKey="true" TextAlign="Syncfusion.Blazor.Grids.TextAlign.Right"></TreeGridColumn> | ||
| <TreeGridColumn Field="TaskName" HeaderText="Task Name" Width="160"></TreeGridColumn> | ||
| <TreeGridColumn Field="Duration" HeaderText="Duration" Width="100" TextAlign="Syncfusion.Blazor.Grids.TextAlign.Right"></TreeGridColumn> | ||
| </TreeGridColumns> | ||
| </SfTreeGrid> | ||
|
|
||
| @code { | ||
| public List<TreeData.BusinessObject> TreeGridData { get; set; } | ||
| SfTreeGrid<TreeData.BusinessObject> TreeGrid; | ||
| public bool IsRowSelected { get; set; } = true; | ||
| public bool EnableSave { get; set; } = true; | ||
|
|
||
| protected override void OnInitialized() | ||
| { | ||
| this.TreeGridData = TreeData.GetSelfDataSource().ToList(); | ||
| } | ||
|
|
||
| public void ToolbarClickHandler(Syncfusion.Blazor.Navigations.ClickEventArgs args) | ||
| { | ||
| if (args.Item.Text == "Add") | ||
| { | ||
| this.TreeGrid.AddRecordAsync(); | ||
| EnableSave = false; | ||
| } | ||
| if (args.Item.Text == "Save") | ||
| { | ||
| this.TreeGrid.EndEditAsync(); | ||
| EnableSave = true; | ||
| } | ||
| } | ||
|
|
||
| public void RowSelected(Syncfusion.Blazor.Grids.RowSelectEventArgs<TreeData.BusinessObject> args) | ||
| { | ||
| IsRowSelected = false; | ||
| } | ||
| public void RowDeselected(Syncfusion.Blazor.Grids.RowDeselectEventArgs<TreeData.BusinessObject> args) | ||
| { | ||
| IsRowSelected = true; | ||
| } | ||
|
|
||
| public class TreeData | ||
| { | ||
| public class BusinessObject | ||
| { | ||
| public int TaskId { get; set; } | ||
| public string TaskName { get; set; } | ||
| public int? Duration { get; set; } | ||
| public int? Progress { get; set; } | ||
| public string Priority { get; set; } | ||
| public int? ParentId { get; set; } | ||
| public int? AgendaTopicTypeId { get; set; } | ||
|
|
||
| } | ||
|
|
||
| public static List<BusinessObject> GetSelfDataSource() | ||
| { | ||
| List<BusinessObject> BusinessObjectCollection = new List<BusinessObject>(); | ||
| BusinessObjectCollection.Add(new BusinessObject() { TaskId = 1, TaskName = "Parent Task 1", Duration = 10, Progress = 70, Priority = "Critical", ParentId = null }); | ||
| BusinessObjectCollection.Add(new BusinessObject() { TaskId = 2, TaskName = "Child task 1", Progress = 80, Priority = "Low", ParentId = 1 }); | ||
| BusinessObjectCollection.Add(new BusinessObject() { TaskId = 3, TaskName = "Child Task 2", Duration = 5, Progress = 65, Priority = "Critical", ParentId = 2 }); | ||
| BusinessObjectCollection.Add(new BusinessObject() { TaskId = 4, TaskName = "Child task 3", Duration = 6, Priority = "High", Progress = 77, ParentId = 3 }); | ||
| BusinessObjectCollection.Add(new BusinessObject() { TaskId = 5, TaskName = "Parent Task 2", Duration = 10, Progress = 70, Priority = "Critical", ParentId = null }); | ||
| BusinessObjectCollection.Add(new BusinessObject() { TaskId = 6, TaskName = "Child task 1", Duration = 4, Progress = 80, Priority = "Critical", ParentId = 5 }); | ||
| BusinessObjectCollection.Add(new BusinessObject() { TaskId = 7, TaskName = "Child Task 2", Duration = 5, Progress = 65, Priority = "Low", ParentId = 5 }); | ||
| BusinessObjectCollection.Add(new BusinessObject() { TaskId = 8, TaskName = "Child task 3", Duration = 6, Progress = 77, Priority = "High", ParentId = 5 }); | ||
| BusinessObjectCollection.Add(new BusinessObject() { TaskId = 9, TaskName = "Child task 4", Duration = 6, Progress = 77, Priority = "Low", ParentId = 5 }); | ||
| return BusinessObjectCollection; | ||
| } | ||
| } | ||
| } | ||
| ``` | ||
|
|
||
| {% previewsample "https://blazorplayground.syncfusion.com/embed/VjreWhBUfzxLZRkQ?appbar=true&editor=true&result=true&errorlist=true&theme=bootstrap5" %} | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.