Skip to content

Commit 17b7751

Browse files
authored
docs(FileManager|MultiSelect): Add missing event and parameter (#2389)
* docs(FileManager|MultiSelect): Add missing event and parameter * Update components/filemanager/events.md * Update components/filemanager/events.md
1 parent 37e1801 commit 17b7751

File tree

2 files changed

+34
-16
lines changed

2 files changed

+34
-16
lines changed

components/filemanager/events.md

Lines changed: 33 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ This article explains the events available in the Telerik FileManager for Blazor
2121
* [Other Events](#other-events) - other events the grid provides.
2222
* [OnModelInit](#onmodelinit)
2323
* [OnDownload](#ondownload)
24+
* [PathChanged](#pathchanged)
2425
* [SelectedItemsChanged](#selecteditemschanged)
2526
* [ViewChanged](#viewchanged)
2627

@@ -348,6 +349,10 @@ A FileManager in a WebAssembly app usually displays files from a remote server.
348349
1. The server returns the file content.
349350
1. The `OnDownload` handler puts the returned file content to a `MemoryStream` and assigns it to `args.Stream`.
350351

352+
### PathChanged
353+
354+
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.
355+
351356
### SelectedItemsChanged
352357

353358
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
364369
@using System.IO
365370
366371
<TelerikFileManager Data="@Files"
367-
@bind-Path="@DirectoryPath"
372+
Path="@DirectoryPath"
373+
PathChanged="@OnPathChanged"
368374
View="@CurrentView"
369375
ViewChanged="@OnViewChanged"
370376
Height="400px"
@@ -393,12 +399,12 @@ The `ViewChanged` event fires when the user toggles between the [two FileManager
393399
394400
private async Task OnCreateHandler(FileManagerCreateEventArgs args)
395401
{
396-
var newFolder = args.Item as FlatFileEntry;
402+
var newFolder = (FlatFileEntry)args.Item;
397403
398404
var parent = GetParent(newFolder, DirectoryPath);
399405
400406
newFolder.Id = "20";
401-
newFolder.ParentId = parent.Id;
407+
newFolder.ParentId = parent?.Id;
402408
newFolder.Name = "New folder";
403409
newFolder.IsDirectory = true;
404410
newFolder.HasDirectories = false;
@@ -424,17 +430,17 @@ The `ViewChanged` event fires when the user toggles between the [two FileManager
424430
Files.Add(newFolder);
425431
}
426432
427-
RefreshData();
433+
await RefreshData();
428434
}
429435
430-
private FlatFileEntry GetDirectory(string path)
436+
private FlatFileEntry? GetDirectory(string path)
431437
{
432438
var directory = Files.FirstOrDefault(x => x.IsDirectory && x.Path == path);
433439
434440
return directory;
435441
}
436442
437-
private FlatFileEntry GetParent(FlatFileEntry currItem, string currDirectory)
443+
private FlatFileEntry? GetParent(FlatFileEntry currItem, string currDirectory)
438444
{
439445
var parentItem = Files
440446
.FirstOrDefault(x => x.IsDirectory && x.Path == currDirectory);
@@ -445,7 +451,7 @@ The `ViewChanged` event fires when the user toggles between the [two FileManager
445451
446452
private async Task OnUpdateHandler(FileManagerUpdateEventArgs args)
447453
{
448-
var item = args.Item as FlatFileEntry;
454+
var item = (FlatFileEntry)args.Item;
449455
450456
if (item.IsDirectory)
451457
{
@@ -466,6 +472,8 @@ The `ViewChanged` event fires when the user toggles between the [two FileManager
466472
updatedItem.Path = Path.Combine(DirectoryPath, fullName);
467473
Console.WriteLine(updatedItem.Path);
468474
}
475+
476+
await Task.Delay(1); // simulate async operation
469477
}
470478
471479
private async Task OnDownloadHandler(FileManagerDownloadEventArgs args)
@@ -481,6 +489,7 @@ The `ViewChanged` event fires when the user toggles between the [two FileManager
481489
482490
FlatFileEntry actualFile = (FlatFileEntry)args.Item;
483491
492+
await Task.Delay(1); // simulate async operation
484493
string dummyFileContent = $"This file is a dummy version of {actualFile.Name}. It was downloaded with the Telerik Blazor FileManager.";
485494
byte[] dummyFileBuffer = System.Text.Encoding.UTF8.GetBytes(dummyFileContent);
486495
@@ -491,13 +500,13 @@ The `ViewChanged` event fires when the user toggles between the [two FileManager
491500
492501
private async Task OnDeleteHandler(FileManagerDeleteEventArgs args)
493502
{
494-
var currItem = args.Item as FlatFileEntry;
503+
var item = (FlatFileEntry)args.Item;
495504
496-
var itemToDelete = Files.FirstOrDefault(x => x.Id == currItem.Id);
505+
var itemToDelete = Files.FirstOrDefault(x => x.Id == item.Id);
497506
498507
Files.Remove(itemToDelete);
499508
500-
RefreshData();
509+
await RefreshData();
501510
}
502511
503512
private FlatFileEntry OnModelInitHandler()
@@ -516,14 +525,20 @@ The `ViewChanged` event fires when the user toggles between the [two FileManager
516525
return item;
517526
}
518527
528+
private void OnPathChanged(string newPath)
529+
{
530+
DirectoryPath = newPath;
531+
}
532+
519533
private void OnSelect(IEnumerable<FlatFileEntry> selectedFiles)
520534
{
521535
// Update the view model.
522536
SelectedItems = selectedFiles;
523537
}
524538
525-
private void RefreshData()
539+
private async Task RefreshData()
526540
{
541+
await Task.Delay(1); // simulate async operation
527542
Files = new List<FlatFileEntry>(Files);
528543
}
529544
@@ -534,12 +549,12 @@ The `ViewChanged` event fires when the user toggles between the [two FileManager
534549
535550
public class FlatFileEntry
536551
{
537-
public string Id { get; set; }
538-
public string ParentId { get; set; }
539-
public string Name { get; set; }
552+
public string Id { get; set; } = string.Empty;
553+
public string? ParentId { get; set; }
554+
public string Name { get; set; } = string.Empty;
540555
public long Size { get; set; }
541-
public string Path { get; set; }
542-
public string Extension { get; set; }
556+
public string Path { get; set; } = string.Empty;
557+
public string Extension { get; set; } = string.Empty;
543558
public bool IsDirectory { get; set; }
544559
public bool HasDirectories { get; set; }
545560
public DateTime DateCreated { get; set; }
@@ -674,6 +689,8 @@ The `ViewChanged` event fires when the user toggles between the [two FileManager
674689
gridDesign
675690
};
676691
692+
await Task.Delay(1); // simulate async operation
693+
677694
return files;
678695
}
679696
}

components/multiselect/overview.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,7 @@ The Blazor MultiSelect provides various parameters that allow you to configure t
111111
| `MinLength` | `int` | How many characters the user must type before the suggestion list appears. Often works together with [filtering]({%slug multiselect-filter%}). |
112112
| `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"`.
113113
| `Placeholder` | `string` | The text the user sees as a hint when there is no selection. |
114+
| `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. |
114115
| `TextField` | `string` <br /> (`Text`)| The field in the model from which the text of the items is taken. |
115116
| `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. |
116117
| `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:<br /> - `number` (such as `int`, `double`, and so on)<br /> - `string`<br /> - `Guid`<br /> - `Enum` |

0 commit comments

Comments
 (0)