From 4ad3b92b82ef5aa3c35344dfb598cb14026587ae Mon Sep 17 00:00:00 2001 From: Dimo Dimov <961014+dimodi@users.noreply.github.com> Date: Fri, 20 Sep 2024 09:47:55 +0300 Subject: [PATCH 1/3] docs(FileManager|MultiSelect): Add missing event and parameter --- components/filemanager/events.md | 49 ++++++++++++++++++++---------- components/multiselect/overview.md | 1 + 2 files changed, 34 insertions(+), 16 deletions(-) diff --git a/components/filemanager/events.md b/components/filemanager/events.md index e33375b3f4..d366636bd7 100644 --- a/components/filemanager/events.md +++ b/components/filemanager/events.md @@ -21,6 +21,7 @@ This article explains the events available in the Telerik FileManager for Blazor * [Other Events](#other-events) - other events the grid provides. * [OnModelInit](#onmodelinit) * [OnDownload](#ondownload) + * [PathChanged](#ondownload) * [SelectedItemsChanged](#selecteditemschanged) * [ViewChanged](#viewchanged) @@ -348,6 +349,10 @@ A FileManager in a WebAssembly app usually displays files from a remote server. 1. The server returns the file content. 1. The `OnDownload` handler puts the returned file content to a `MemoryStream` and assigns it to `args.Stream`. +### PathChanged + +The `PathChanged` event fires when the user navigates to a different folder through the TreeView or by double-clicking a folder item in the View. The event handler receives the new path as a `string` argument. + ### SelectedItemsChanged The `SelectedItemChanged` event fires every time the user clicks on a new file/folder in the main pane of the FileManager. You can use it with one-way binding of the `SelectedItems` parameter to respond to user selection. @@ -364,7 +369,8 @@ The `ViewChanged` event fires when the user toggles between the [two FileManager @using System.IO x.IsDirectory && x.Path == path); return directory; } - private FlatFileEntry GetParent(FlatFileEntry currItem, string currDirectory) + private FlatFileEntry? GetParent(FlatFileEntry currItem, string currDirectory) { var parentItem = Files .FirstOrDefault(x => x.IsDirectory && x.Path == currDirectory); @@ -445,7 +451,7 @@ The `ViewChanged` event fires when the user toggles between the [two FileManager private async Task OnUpdateHandler(FileManagerUpdateEventArgs args) { - var item = args.Item as FlatFileEntry; + var item = (FlatFileEntry)args.Item; if (item.IsDirectory) { @@ -466,6 +472,8 @@ The `ViewChanged` event fires when the user toggles between the [two FileManager updatedItem.Path = Path.Combine(DirectoryPath, fullName); Console.WriteLine(updatedItem.Path); } + + await Task.Delay(1); // simulate async operation } private async Task OnDownloadHandler(FileManagerDownloadEventArgs args) @@ -481,6 +489,7 @@ The `ViewChanged` event fires when the user toggles between the [two FileManager FlatFileEntry actualFile = (FlatFileEntry)args.Item; + await Task.Delay(1); // simulate async operation string dummyFileContent = $"This file is a dummy version of {actualFile.Name}. It was downloaded with the Telerik Blazor FileManager."; byte[] dummyFileBuffer = System.Text.Encoding.UTF8.GetBytes(dummyFileContent); @@ -491,13 +500,13 @@ The `ViewChanged` event fires when the user toggles between the [two FileManager private async Task OnDeleteHandler(FileManagerDeleteEventArgs args) { - var currItem = args.Item as FlatFileEntry; + var item = (FlatFileEntry)args.Item; - var itemToDelete = Files.FirstOrDefault(x => x.Id == currItem.Id); + var itemToDelete = Files.FirstOrDefault(x => x.Id == item.Id); Files.Remove(itemToDelete); - RefreshData(); + await RefreshData(); } private FlatFileEntry OnModelInitHandler() @@ -516,14 +525,20 @@ The `ViewChanged` event fires when the user toggles between the [two FileManager return item; } + private void OnPathChanged(string newPath) + { + DirectoryPath = newPath; + } + private void OnSelect(IEnumerable selectedFiles) { // Update the view model. SelectedItems = selectedFiles; } - private void RefreshData() + private async Task RefreshData() { + await Task.Delay(1); // simulate async operation Files = new List(Files); } @@ -534,12 +549,12 @@ The `ViewChanged` event fires when the user toggles between the [two FileManager public class FlatFileEntry { - public string Id { get; set; } - public string ParentId { get; set; } - public string Name { get; set; } + public string Id { get; set; } = string.Empty; + public string? ParentId { get; set; } + public string Name { get; set; } = string.Empty; public long Size { get; set; } - public string Path { get; set; } - public string Extension { get; set; } + public string Path { get; set; } = string.Empty; + public string Extension { get; set; } = string.Empty; public bool IsDirectory { get; set; } public bool HasDirectories { get; set; } public DateTime DateCreated { get; set; } @@ -674,6 +689,8 @@ The `ViewChanged` event fires when the user toggles between the [two FileManager gridDesign }; + await Task.Delay(1); // simulate async operation + return files; } } diff --git a/components/multiselect/overview.md b/components/multiselect/overview.md index d2587c52f9..905d0a8b75 100644 --- a/components/multiselect/overview.md +++ b/components/multiselect/overview.md @@ -111,6 +111,7 @@ The Blazor MultiSelect provides various parameters that allow you to configure t | `MinLength` | `int` | How many characters the user must type before the suggestion list appears. Often works together with [filtering]({%slug multiselect-filter%}). | | `PersistFilterOnSelect` | `bool` | Controls whether the filter input will be cleared when the user selects an item. Applies when [MultiSelect filtering]({%slug multiselect-filter%}) is enabled and `AutoClose="false"`. | `Placeholder` | `string` | The text the user sees as a hint when there is no selection. | +| `ShowArrowButton` | `bool` | Controls whether the MultiSelect will show an arrow button, which hints about its dropdown. When enabled, an empty MultiSelect component looks similar to a ComboBox, otherwise it looks similar to a TextBox. | | `TextField` | `string`
(`Text`)| The field in the model from which the text of the items is taken. | | `TItem` | `Type` | The type of the model to which the component is bound. Required if you can't provide `Data` or `Value`. Determines the type of the reference object. | | `TValue` | `Type` | The type of the value field in the model to which the component is bound. Required if you can't provide `Data` or `Value`. Determines the type of the reference object. The type of the values can be:
- `number` (such as `int`, `double`, and so on)
- `string`
- `Guid`
- `Enum` | From 5fe9e478a2f94e9287640b5b666ba91d1c882c39 Mon Sep 17 00:00:00 2001 From: Dimo Dimov <961014+dimodi@users.noreply.github.com> Date: Fri, 20 Sep 2024 10:03:32 +0300 Subject: [PATCH 2/3] Update components/filemanager/events.md --- components/filemanager/events.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/filemanager/events.md b/components/filemanager/events.md index d366636bd7..3091eb9f29 100644 --- a/components/filemanager/events.md +++ b/components/filemanager/events.md @@ -351,7 +351,7 @@ A FileManager in a WebAssembly app usually displays files from a remote server. ### PathChanged -The `PathChanged` event fires when the user navigates to a different folder through the TreeView or by double-clicking a folder item in the View. The event handler receives the new path as a `string` argument. +The `PathChanged` event fires when the user navigates to a different folder through the TreeView or by double-clicking a folder item in the [FileManager View]({%slug filemanager-views%}). The event handler receives the new path as a `string` argument. ### SelectedItemsChanged From af0091f8f28aef983c0eda1915cb147b776afe2c Mon Sep 17 00:00:00 2001 From: Dimo Dimov <961014+dimodi@users.noreply.github.com> Date: Fri, 20 Sep 2024 10:45:24 +0300 Subject: [PATCH 3/3] Update components/filemanager/events.md --- components/filemanager/events.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/filemanager/events.md b/components/filemanager/events.md index 3091eb9f29..6aa6278a24 100644 --- a/components/filemanager/events.md +++ b/components/filemanager/events.md @@ -21,7 +21,7 @@ This article explains the events available in the Telerik FileManager for Blazor * [Other Events](#other-events) - other events the grid provides. * [OnModelInit](#onmodelinit) * [OnDownload](#ondownload) - * [PathChanged](#ondownload) + * [PathChanged](#pathchanged) * [SelectedItemsChanged](#selecteditemschanged) * [ViewChanged](#viewchanged)