diff --git a/blazor/treegrid/editing/cell-edit-types.md b/blazor/treegrid/editing/cell-edit-types.md index 6ea22ebb1f..0bc75fa86f 100644 --- a/blazor/treegrid/editing/cell-edit-types.md +++ b/blazor/treegrid/editing/cell-edit-types.md @@ -457,6 +457,124 @@ public class TreeData ![Blazor Tree Grid with NumericTextBox Edit Template](../images/blazor-treegrid-numerictextbox-edit-template.webp) +### Render TextArea in EditTemplate + +The Syncfusion® Blazor TreeGrid supports rendering a [SfTextArea](https://blazor.syncfusion.com/documentation/textarea/getting-started-webapp) within the TreeGrid's edit form for specific columns. This functionality is useful for editing and displaying multi-line text content, providing an efficient way to manage extensive text data within TreeGrid cells. + +To render a `SfTextArea` in the edit form, define an [EditTemplate](https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.TreeGrid.TreeGridColumn.html#Syncfusion_Blazor_TreeGrid_TreeGridColumn_Template) in the [TreeGridColumn](https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.TreeGrid.TreeGridColumn.html). The `EditTemplate` property specifies the cell edit template used as an editor for the column and accepts either a template string or an HTML element ID. + +> When using a `SfTextArea`, press **Shift+Enter** to insert a new line. By default, pressing **Enter** triggers a record update while in edit mode. + +{% tabs %} +{% highlight razor tabtitle="Index.razor" %} + +@page "/" +@using Syncfusion.Blazor.TreeGrid +@using Syncfusion.Blazor.Inputs +@using Syncfusion.Blazor.Buttons + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +@code { + + public class TreeItem + { + public int TaskId { get; set; } + public string TaskName { get; set; } + public string Description { get; set; } + public bool Approved { get; set; } + public int? ParentId { get; set; } + } + + public List TreeGridData { get; set; } + + protected override void OnInitialized() + { + TreeGridData = new List + { + new TreeItem + { + TaskId = 1, + TaskName = "Parent Task 1", + Description = "This is a parent task.\nMultiline text supported.", + Approved = true, + ParentId = null + }, + new TreeItem + { + TaskId = 2, + TaskName = "Child Task 1", + Description = "Child task description", + Approved = false, + ParentId = 1 + }, + new TreeItem + { + TaskId = 3, + TaskName = "Child Task 2", + Description = "Another child task", + Approved = true, + ParentId = 1 + } + }; + } +} +{% endhighlight %} +{% endtabs %} + +{% previewsample "https://blazorplayground.syncfusion.com/embed/VDBdteZPTqGFpSWM?appbar=true&editor=true&result=true&errorlist=false&theme=fluent2" %} + + ### Using TimePicker in EditTemplate Render the [SfTimePicker](https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.Calendars.SfTimePicker-1.html) component for the edit form field in tree grid using [EditTemplate](https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.TreeGrid.TreeGridColumn.html#Syncfusion_Blazor_TreeGrid_TreeGridColumn_EditTemplate). In the following sample, `SfTimePicker` component is rendered in the `EditTemplate` for the **StartDate** column. @@ -764,4 +882,4 @@ public class TreeData {% endtabs %} In the following image, `SfRichTextEditor` component is rendered with the `EditTemplate` in the **TaskName** column -![Blazor Tree Grid with Editing in Custom RichTextEditor](../images/blazor-treegrid-editing-in-custom-richtexteditor.webp) \ No newline at end of file +![Blazor Tree Grid with Editing in Custom RichTextEditor](../images/blazor-treegrid-editing-in-custom-richtexteditor.webp) diff --git a/blazor/treegrid/editing/edit.md b/blazor/treegrid/editing/edit.md index 7730305217..90af1b2f3f 100644 --- a/blazor/treegrid/editing/edit.md +++ b/blazor/treegrid/editing/edit.md @@ -925,6 +925,89 @@ public class TreeData The following GIF shows the TreeGrid with a custom external form for editing. ![Blazor TreeGrid with Custom External form Editing](../images/blazor-treegrid-custom-form-editing.webp) +## Update boolean column value with a single click + +The Syncfusion® Blazor TreeGrid supports updating boolean column values with a single click in normal editing mode. This feature streamlines the process of toggling boolean values directly within the TreeGrid, improving interaction efficiency. + +This behavior can be achieved using the [column template](https://blazor.syncfusion.com/documentation/treegrid/columns/column-template) feature. The column template allows custom UI elements, such as checkboxes, to be rendered for specific columns. By configuring the [Template](https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.TreeGrid.TreeGridColumn.html#Syncfusion_Blazor_TreeGrid_TreeGridColumn_Template) property, a checkbox can be rendered in the desired column, and its change event can be handled to update the value with a single click. + +{% tabs %} +{% highlight razor tabtitle="Index.razor" %} + +@page "/" +@using Syncfusion.Blazor.Buttons +@using Syncfusion.Blazor.TreeGrid; + + + + + + + + + + + + + + +@code { + + public List TreeGridData { get; set; } + protected override void OnInitialized() + { + this.TreeGridData = TreeData.GetSelfDataSource().ToList(); + } +} +{% endhighlight %} + +{% highlight c# tabtitle="BusinessObject.cs" %} + + 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 bool Approved { get; set; } + public int? ParentId { get; set; } + public string Priority { get; set; } + } + + public static List GetSelfDataSource() + { + List BusinessObjectCollection = new List(); + BusinessObjectCollection.Add(new BusinessObject() { TaskId = 1, TaskName = "Parent Task 1", Duration = 10, Progress = 70, Priority = "Critical", ParentId = null, Approved = true }); + BusinessObjectCollection.Add(new BusinessObject() { TaskId = 2, TaskName = "Child task 1", Duration = 10, Progress = 80, Priority = "Low", ParentId = 1, Approved = false }); + BusinessObjectCollection.Add(new BusinessObject() { TaskId = 3, TaskName = "Child Task 2", Duration = 5, Progress = 65, Priority = "Critical", ParentId = 2, Approved = false }); + BusinessObjectCollection.Add(new BusinessObject() { TaskId = 4, TaskName = "Child task 3", Duration = 6, Priority = "High", Progress = 77, ParentId = 3, Approved = true}); + BusinessObjectCollection.Add(new BusinessObject() { TaskId = 5, TaskName = "Parent Task 2", Duration = 10, Progress = 70, Priority = "Critical", ParentId = null, Approved = true }); + BusinessObjectCollection.Add(new BusinessObject() { TaskId = 6, TaskName = "Child task 1", Duration = 4, Progress = 80, Priority = "Critical", ParentId = 5, Approved = false }); + BusinessObjectCollection.Add(new BusinessObject() { TaskId = 7, TaskName = "Child Task 2", Duration = 5, Progress = 65, Priority = "Low", ParentId = 5, Approved = true }); + BusinessObjectCollection.Add(new BusinessObject() { TaskId = 8, TaskName = "Child task 3", Duration = 6, Progress = 77, Priority = "High", ParentId = 5, Approved = false }); + BusinessObjectCollection.Add(new BusinessObject() { TaskId = 9, TaskName = "Child task 4", Duration = 6, Progress = 77, Priority = "Low", ParentId = 5, Approved = true }); + return BusinessObjectCollection; + } + } + +{% endhighlight %} +{% endtabs %} + +{% previewsample "https://blazorplayground.syncfusion.com/embed/VjLRZIXlqbyFAgDQ?appbar=true&editor=true&result=true&errorlist=true&theme=fluent2" %} + ## Edit enum column Edit enum type data in a TreeGrid column using the [EditTemplate](https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.TreeGrid.TreeGridColumn.html#Syncfusion_Blazor_TreeGrid_TreeGridColumn_EditTemplate).