-
Notifications
You must be signed in to change notification settings - Fork 80
docs(grid,treelist):add section and kb for delete confirmation dialog #409
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
Merged
xristianstefanov
merged 3 commits into
master
from
docs-for-delete-confirmation-in-grid-treelist
Jul 30, 2021
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
a9054a6
docs(grid,treelist):add section and kb for delete confirmation dialog
xristianstefanov df4e59a
chore(grid,treelist):removed kb and added a new folder in grid/treeli…
xristianstefanov 5f7caa6
chore(grid,treelist):small fixes as per comment
xristianstefanov 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
102 changes: 102 additions & 0 deletions
102
components/grid/editing/built-in-dialogs/delete-confirmation.md
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,102 @@ | ||
| --- | ||
| title: Delete Confirmation | ||
| page_title: Grid - Delete Confirmation Dialog | ||
| description: Enable delete confirmation dialog in Grid for Blazor. | ||
| slug: grid-delete-confirmation | ||
| tags: telerik,blazor,grid,delete,confirmation,dialog | ||
| published: True | ||
| position: 3 | ||
| --- | ||
|
|
||
| # Delete Confirmation Dialog | ||
| The delete confirmation dialog triggers before item deletion. You can enable it by setting the `ConfirmDelete` parameter of the Grid to `true`. | ||
|
|
||
| >caption Delete Confirmation dialog | ||
|
|
||
|  | ||
|
|
||
| >caption Enabling of the Delete Confirmation Dialog | ||
|
|
||
| ````CSHTML | ||
| @* Grid with enabled Delete Confirmation Dialog *@ | ||
|
|
||
| @using System.ComponentModel.DataAnnotations | ||
|
|
||
| <TelerikGrid Data=@MyData Pageable="true" Height="400px" | ||
| OnDelete="@DeleteHandler" ConfirmDelete="true"> | ||
| <GridColumns> | ||
| <GridColumn Field=@nameof(SampleData.ID) Title="ID" /> | ||
| <GridColumn Field=@nameof(SampleData.Name) Title="Name" /> | ||
| <GridCommandColumn> | ||
| <GridCommandButton Command="Delete" Icon="delete">Delete</GridCommandButton> | ||
| </GridCommandColumn> | ||
| </GridColumns> | ||
| </TelerikGrid> | ||
|
|
||
| @code { | ||
| async Task DeleteHandler(GridCommandEventArgs args) | ||
| { | ||
| SampleData item = (SampleData)args.Item; | ||
|
|
||
| await MyService.Delete(item); | ||
|
|
||
| await GetGridData(); | ||
| } | ||
|
|
||
| public class SampleData | ||
| { | ||
| public int ID { get; set; } | ||
| [Required] | ||
| public string Name { get; set; } | ||
| } | ||
|
|
||
| List<SampleData> MyData { get; set; } | ||
|
|
||
| async Task GetGridData() | ||
| { | ||
| MyData = await MyService.Read(); | ||
| } | ||
|
|
||
| protected override async Task OnInitializedAsync() | ||
| { | ||
| await GetGridData(); | ||
| } | ||
|
|
||
| public static class MyService | ||
| { | ||
| private static List<SampleData> _data { get; set; } = new List<SampleData>(); | ||
|
|
||
| public static async Task<List<SampleData>> Read() | ||
| { | ||
| if (_data.Count < 1) | ||
| { | ||
| for (int i = 1; i < 50; i++) | ||
| { | ||
| _data.Add(new SampleData() | ||
| { | ||
| ID = i, | ||
| Name = "Name " + i.ToString() | ||
| }); | ||
| } | ||
| } | ||
|
|
||
| return await Task.FromResult(_data); | ||
| } | ||
|
|
||
| public static async Task Delete(SampleData itemToDelete) | ||
| { | ||
| _data.Remove(itemToDelete); | ||
| } | ||
| } | ||
| } | ||
| ```` | ||
|
|
||
|
|
||
| ## See Also | ||
|
|
||
| * [Live Demo: Grid Inline Editing](https://demos.telerik.com/blazor-ui/grid/editing-inline) | ||
| * [Live Demo: Grid PopUp Editing](https://demos.telerik.com/blazor-ui/grid/editing-popup) | ||
| * [Live Demo: Grid InCell Editing](https://demos.telerik.com/blazor-ui/grid/editing-incell) | ||
| * [Live Demo: Grid Custom Editor Template](https://demos.telerik.com/blazor-ui/grid/custom-editor) | ||
| * [Live Demo: Grid Custom Edit Form](https://demos.telerik.com/blazor-ui/grid/editing-custom-form) | ||
|
|
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,28 @@ | ||
| --- | ||
| title: Overview | ||
| page_title: Editing - Built-in Dialogs Overview | ||
| description: Enable built-in dialogs in Grid for Blazor. | ||
| slug: components/grid/features/built-in-dialogs | ||
| tags: telerik,blazor,grid,built,in,dialogs | ||
| published: True | ||
| previous_url: /grid/built-in-dialogs | ||
| position: 0 | ||
| --- | ||
|
|
||
| # Grid Built-in Dialogs | ||
| You can enable built-in dialogs in Grid to provide an extra step for the end-user before a Grid operation. | ||
|
|
||
| The Grid component can use built-in dialogs for: | ||
|
|
||
| * [delete confirmation]({%slug grid-delete-confirmation%}) - displays a confirmation dialog when the user clicks the "**delete**" command button. | ||
|
|
||
| The default texts of the dialogs are exposed in the [localization]({%slug globalization-localization%}) messages of the component, and you can customize them. | ||
|
|
||
| ## See Also | ||
|
|
||
| * [Live Demo: Grid Inline Editing](https://demos.telerik.com/blazor-ui/grid/editing-inline) | ||
| * [Live Demo: Grid PopUp Editing](https://demos.telerik.com/blazor-ui/grid/editing-popup) | ||
| * [Live Demo: Grid InCell Editing](https://demos.telerik.com/blazor-ui/grid/editing-incell) | ||
| * [Live Demo: Grid Custom Editor Template](https://demos.telerik.com/blazor-ui/grid/custom-editor) | ||
| * [Live Demo: Grid Custom Edit Form](https://demos.telerik.com/blazor-ui/grid/editing-custom-form) | ||
|
|
||
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
179 changes: 179 additions & 0 deletions
179
components/treelist/editing/built-in-dialogs/delete-confirmation.md
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,179 @@ | ||
| --- | ||
| title: Delete Confirmation | ||
| page_title: TreeList - Delete Confirmation Dialog | ||
| description: Enable delete confirmation dialog in TreeList for Blazor. | ||
| slug: treelist-delete-confirmation | ||
| tags: telerik,blazor,treelist,delete,confirmation,dialog | ||
| published: True | ||
| position: 3 | ||
| --- | ||
|
|
||
| # Delete Confirmation Dialog | ||
| The delete confirmation dialog triggers before item deletion. You can enable it by setting the `ConfirmDelete` parameter of the TreeList to `true`. | ||
|
|
||
| >caption Delete Confirmation dialog | ||
|
|
||
|  | ||
|
|
||
| >caption Enabling of the Delete Confirmation Dialog | ||
|
|
||
| ````CSHTML | ||
| @* TreeList with enabled Delete Confirmation Dialog *@ | ||
|
|
||
| @using System.ComponentModel.DataAnnotations | ||
|
|
||
| <TelerikTreeList Data="@Data" | ||
| OnDelete="@DeleteItem" | ||
| Pageable="true" Height="400px" | ||
| ConfirmDelete="true"> | ||
| <TreeListColumns> | ||
| <TreeListCommandColumn> | ||
| <TreeListCommandButton Command="Delete" Icon="delete">Delete</TreeListCommandButton> | ||
| </TreeListCommandColumn> | ||
| <TreeListColumn Field="Name" Expandable="true" /> | ||
| <TreeListColumn Field="Id" /> | ||
| <TreeListColumn Field="EmailAddress" /> | ||
| <TreeListColumn Field="HireDate" /> | ||
| </TreeListColumns> | ||
| </TelerikTreeList> | ||
|
|
||
| @code { | ||
| public List<Employee> Data { get; set; } | ||
|
|
||
| async Task DeleteItem(TreeListCommandEventArgs args) | ||
| { | ||
| var item = args.Item as Employee; | ||
|
|
||
| await MyService.Delete(item); | ||
|
|
||
| await GetTreeListData(); | ||
| } | ||
|
|
||
| public class Employee | ||
| { | ||
| public int Id { get; set; } | ||
|
|
||
| [Required] | ||
| public string Name { get; set; } | ||
| public string EmailAddress { get; set; } | ||
| public DateTime HireDate { get; set; } | ||
|
|
||
| public List<Employee> DirectReports { get; set; } | ||
| public bool HasChildren { get; set; } | ||
|
|
||
| public override bool Equals(object obj) | ||
| { | ||
| if (obj is Employee) | ||
| { | ||
| return this.Id == (obj as Employee).Id; | ||
| } | ||
| return false; | ||
| } | ||
| } | ||
|
|
||
| async Task GetTreeListData() | ||
| { | ||
| Data = await MyService.Read(); | ||
| } | ||
|
|
||
| protected override async Task OnInitializedAsync() | ||
| { | ||
| await GetTreeListData(); | ||
| } | ||
|
|
||
| public static class MyService | ||
| { | ||
| private static List<Employee> _data { get; set; } = new List<Employee>(); | ||
| private static int LastId { get; set; } = 1; | ||
|
|
||
| public static async Task<List<Employee>> Read() | ||
| { | ||
| if (_data.Count < 1) | ||
| { | ||
| for (int i = 1; i < 15; i++) | ||
| { | ||
| Employee root = new Employee | ||
| { | ||
| Id = LastId, | ||
| Name = $"root: {i}", | ||
| EmailAddress = $"{i}@example.com", | ||
| HireDate = DateTime.Now.AddYears(-i), | ||
| DirectReports = new List<Employee>(), | ||
| HasChildren = true | ||
| }; | ||
| _data.Add(root); | ||
| LastId++; | ||
|
|
||
| for (int j = 1; j < 4; j++) | ||
| { | ||
| int currId = LastId; | ||
| Employee firstLevelChild = new Employee | ||
| { | ||
| Id = currId, | ||
| Name = $"first level child {j} of {i}", | ||
| EmailAddress = $"{currId}@example.com", | ||
| HireDate = DateTime.Now.AddDays(-currId), | ||
| DirectReports = new List<Employee>(), | ||
| HasChildren = true | ||
| }; | ||
| root.DirectReports.Add(firstLevelChild); | ||
| LastId++; | ||
|
|
||
| for (int k = 1; k < 3; k++) | ||
| { | ||
| int nestedId = LastId; | ||
| firstLevelChild.DirectReports.Add(new Employee | ||
| { | ||
| Id = LastId, | ||
| Name = $"second level child {k} of {j} and {i}", | ||
| EmailAddress = $"{nestedId}@example.com", | ||
| HireDate = DateTime.Now.AddMinutes(-nestedId) | ||
| }); ; | ||
| LastId++; | ||
| } | ||
| } | ||
| } | ||
| } | ||
|
|
||
| return await Task.FromResult(_data); | ||
| } | ||
|
|
||
| public static async Task Delete(Employee itemToDelete) | ||
| { | ||
| RemoveChildRecursive(_data, itemToDelete); | ||
| } | ||
|
|
||
| static void RemoveChildRecursive(List<Employee> items, Employee item) | ||
| { | ||
| for (int i = 0; i < items.Count(); i++) | ||
| { | ||
| if (item.Equals(items[i])) | ||
| { | ||
| items.Remove(item); | ||
|
|
||
| return; | ||
| } | ||
| else if (items[i].DirectReports?.Count > 0) | ||
| { | ||
| RemoveChildRecursive(items[i].DirectReports, item); | ||
|
|
||
| if (items[i].DirectReports.Count == 0) | ||
| { | ||
| items[i].HasChildren = false; | ||
| } | ||
| } | ||
| } | ||
| } | ||
| } | ||
| } | ||
| ```` | ||
|
|
||
|
|
||
| ## See Also | ||
|
|
||
| * [Live Demo: TreeList Inline Editing](https://demos.telerik.com/blazor-ui/treelist/editing-inline) | ||
| * [Live Demo: TreeList PopUp Editing](https://demos.telerik.com/blazor-ui/treelist/editing-popup) | ||
| * [Live Demo: TreeList InCell Editing](https://demos.telerik.com/blazor-ui/treelist/editing-incell) | ||
| * [Live Demo: TreeList Custom Editor Template](https://demos.telerik.com/blazor-ui/treelist/custom-editor) | ||
| * [Live Demo: TreeList Custom Edit Form](https://demos.telerik.com/blazor-ui/treelist/editing-custom-form) | ||
|
|
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,28 @@ | ||
| --- | ||
| title: Overview | ||
| page_title: Editing - Built-in Dialogs Overview | ||
| description: Enable built-in dialogs in TreeList for Blazor. | ||
| slug: components/treelist/features/built-in-dialogs | ||
| tags: telerik,blazor,treelist,built,in,dialogs | ||
| published: True | ||
| previous_url: /treelist/built-in-dialogs | ||
| position: 0 | ||
| --- | ||
|
|
||
| # TreeList Built-in Dialogs | ||
| You can enable built-in dialogs in TreeList to provide an extra step for the end-user before a TreeList operation. | ||
|
|
||
| The TreeList component can use built-in dialogs for: | ||
|
|
||
| * [delete confirmation]({%slug treelist-delete-confirmation%}) - displays a confirmation dialog when the user clicks the "**delete**" command button. | ||
|
|
||
| The default texts of the dialogs are exposed in the [localization]({%slug globalization-localization%}) messages of the component, and you can customize them. | ||
|
|
||
| ## See Also | ||
|
|
||
| * [Live Demo: TreeList Inline Editing](https://demos.telerik.com/blazor-ui/treelist/editing-inline) | ||
| * [Live Demo: TreeList PopUp Editing](https://demos.telerik.com/blazor-ui/treelist/editing-popup) | ||
| * [Live Demo: TreeList InCell Editing](https://demos.telerik.com/blazor-ui/treelist/editing-incell) | ||
| * [Live Demo: TreeList Custom Editor Template](https://demos.telerik.com/blazor-ui/treelist/custom-editor) | ||
| * [Live Demo: TreeList Custom Edit Form](https://demos.telerik.com/blazor-ui/treelist/editing-custom-form) | ||
|
|
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
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.