Skip to content

Commit f5ad0c5

Browse files
ntachevadmihaylodimodi
authored
[4.1.] DropZone and drop support docs (#1347)
* docs(dropzone):draft docs * docs(dropzone): add more information and samples * docs(dropzone): DropZone and drop support docs * add minor changes * Update components/dropzone/overview.md Co-authored-by: Dimo Dimov <961014+dimodi@users.noreply.github.com> * Update components/dropzone/overview.md Co-authored-by: Dimo Dimov <961014+dimodi@users.noreply.github.com> * Update components/dropzone/overview.md Co-authored-by: Dimo Dimov <961014+dimodi@users.noreply.github.com> * docs(dropzone):address feedback * docs(dropzone):address feedback * docs(upload,fileselect): fixes --------- Co-authored-by: dmihaylo <dmihaylo@progress.com> Co-authored-by: Dimo Dimov <961014+dimodi@users.noreply.github.com>
1 parent 9b5c157 commit f5ad0c5

File tree

8 files changed

+188
-59
lines changed

8 files changed

+188
-59
lines changed

_config.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -329,6 +329,8 @@ navigation:
329329
title: "Drawer"
330330
"*dropdownlist":
331331
title: "DropDownList"
332+
"*dropzone":
333+
title: "DropZone"
332334
"*dropdowntree":
333335
isNew: true
334336
title: "DropDownTree"

components/dropdownlist/overview.md

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
title: Overview
3-
page_title: DropDown List Overview
3+
page_title: DropDownList Overview
44
description: Discover the Blazor DropdownList for Blazor and explore the examples.
55
slug: components/dropdownlist/overview
66
tags: telerik,blazor,dropdownlist,dropdown,list,overview
@@ -12,7 +12,7 @@ position: 0
1212

1313
The <a href="https://www.telerik.com/blazor-ui/dropdownlist" target="_blank">Blazor DropDownList component</a> allows the user to choose an option from a predefined set of choices presented in a dropdown popup. The developer can control the [data]({%slug components/dropdownlist/databind%}), sizes, and various appearance options like class and [templates]({%slug components/dropdownlist/templates%}).
1414

15-
## Creating DropDownList
15+
## Creating the DropDownList
1616

1717
1. Use the `TelerikDropDownList` tag to add the component to your razor page.
1818
1. Populate its `Data` property with the collection of items you want to appear in the dropdown.
@@ -107,7 +107,7 @@ The following parameters enable you to customize the appearance of the Blazor Dr
107107
You can find more options for customizing the DropDownList styling in the [Appearance article]({%slug dropdownlist-appearance%}).
108108

109109

110-
### Popup settings
110+
### Popup Settings
111111

112112
The popup of the component can be additionally customized via nested tags:
113113

@@ -135,7 +135,7 @@ Add a reference to the component instance to use the [DropDownList's methods](/b
135135
````CSHTML
136136
<TelerikDropDownList @ref="@DropDownListRef"
137137
Data="@DropDownListData"
138-
@bind-Value="@DropDownListValue"
138+
@bind-Value="@DropDownListValue"
139139
Width="300px"/>
140140
141141
<TelerikButton OnClick="@OpenPopup">Open Popup</TelerikButton>
@@ -160,7 +160,7 @@ By default, if no `Value` is provided and no `DefaultText` is defined, the DropD
160160

161161
* To display `DefaultText` - `Value` should be `0` or `null` depending on the data type you are using in the `ValueField` and the `DefaultText` should be defined.
162162

163-
* To display a selected item when the component renders - provide the `Value` of the desired element. Note that it must match an item of the component's data source.
163+
* To display a selected item when the component renders - provide the `Value` of the desired element. Note that it must match an item of the component's data source.
164164

165165

166166
## Examples
@@ -240,12 +240,10 @@ By default, if no `Value` is provided and no `DefaultText` is defined, the DropD
240240
## Next Steps
241241

242242
* [Binding the DropDownList to Data]({%slug components/dropdownlist/databind%})
243-
244243
* [Pre-Selecting Items for the User]({% slug dropdownlist-pre-select-item %})
245244

246-
247245
## See Also
248246

249-
* [Data Binding]({%slug components/dropdownlist/databind%})
250-
* [Live Demo: DropDownList](https://demos.telerik.com/blazor-ui/dropdownlist/index)
251-
* [Live Demo: DropDownList Validation](https://demos.telerik.com/blazor-ui/dropdownlist/validation)
247+
* [Data Binding]({%slug components/dropdownlist/databind%})
248+
* [Live Demo: DropDownList](https://demos.telerik.com/blazor-ui/dropdownlist/index)
249+
* [Live Demo: DropDownList Validation](https://demos.telerik.com/blazor-ui/dropdownlist/validation)

components/dropzone/overview.md

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
---
2+
title: Overview
3+
page_title: DropZone Overview and Key Features
4+
description: Discover the Telerik UI for Blazor DropZone, learn how to create the component, integrate it with the Upload and FileSelect controls, use its templaes, parameters, style its appearance, and explore its examples.
5+
slug: dropzone-overview
6+
tags: telerik,blazor,dropzone,external,drag,drop,file,overview
7+
published: True
8+
position: 0
9+
---
10+
11+
# Blazor DropZone Overview
12+
13+
The <a href="https://www.telerik.com/blazor-ui/dropzone" target="_blank">Telerik UI for Blazor DropZone component</a> allows you to declare an external drop zone for an existing [FileSelect]({%slug fileselect-overview%}) or [Upload]({%slug upload-overview%}) component.
14+
15+
This integration enables the users to drag and drop one or multiple files to a designated space in their viewport. Dropping the files in the connected DropZone area will automatically select or upload them respectively.
16+
17+
## Creating Blazor DropZone
18+
19+
1. Add the DropZone to your Razor page by using the `TelerikDropZone` tag.
20+
1. Set the `Id` parameter of the component.
21+
1. Set the `DropZoneId` of the [FileSelect]({%slug fileselect-overview%}#fileselect-parameters) or [Upload]({%slug upload-overview%}#upload-parameters) component to match the `Id` of the DropZone.
22+
1. (Optional) Add a note to the DropZone by using the `NoteText` setting.
23+
24+
>caption Basic configuration of the DropZone with the FileSelect component.
25+
````CSHTML
26+
<TelerikDropZone Id="@DropZoneId" NoteText="@NoteText" />
27+
28+
<TelerikFileSelect DropZoneId="@DropZoneId" AllowedExtensions="@AllowedExtensions" />
29+
30+
@code {
31+
private string DropZoneId => "my-dropzone";
32+
33+
private string NoteText => "Allowed file types: DOCX and PDF";
34+
35+
private List<string> AllowedExtensions { get; set; } = new List<string>() { ".docx", ".pdf" };
36+
}
37+
````
38+
39+
## Integration with the Upload and FileSelect
40+
41+
You can integrate the DropZone with both the [FileSelect]({%slug fileselect-overview%}) or [Upload]({%slug upload-overview%}) components. This will allow users to drop files and automatically select or upload them.
42+
43+
The connection is achieved by simply matching the value of the DropZone `Id` parameter with the `DropZoneId` parameter of the FileSelect or the Upload component.
44+
45+
Once the user drops a file in the external DropZone, the file is automatically sent to the connected FileSelect/Upload. This action effectively raises the `OnSelect` event of the [FileSelect]({%slug fileselect-events%}#onselect) or [Upload]({%slug upload-events%}#onselect). You can handle that to perform further actions with the dropped file(s).
46+
47+
## Template
48+
49+
The DropZone allows you to customize its rendering and appearance through a `Template` configuration. [Read more about using the DropZone template...]({%slug dropzone-template%})
50+
51+
## Parameters
52+
53+
The following table lists DropZone parameters. Check the [DropZone API Reference](/blazor-ui/api/Telerik.Blazor.Components.TelerikDropZone) for a full list of properties, methods and events.
54+
55+
@[template](/_contentTemplates/common/parameters-table-styles.md#table-layout)
56+
57+
| Parameter | Type and Default&nbsp;Value | Description |
58+
| --- | --- | --- |
59+
| `Id` | `string` | The id of the DropZone. Assign the same value of the corresponding Upload or FileSelect component to the `DropZoneId`. |
60+
| `Enabled` | `bool` <br /> (`true`) | Specifies whether the DropZone is enabled. |
61+
| `HintText` | `string` | The text for the hint of the DropZone. If not provided, the DropZone will render a default value ("Drag and drop files here to upload"). The label text is also [localizable]({%slug globalization-localization%}).|
62+
| `NoteText` | `string` | Optional content inside the DropZone. Use it to render any additional information below the hint. The label text is also [localizable]({%slug globalization-localization%}). |
63+
64+
### Styling and Appearance
65+
66+
The following parameters enable you to customize the appearance of the Blazor DropZone:
67+
68+
| Parameter | Type | Description |
69+
| ----------- | ----------- | ----------- |
70+
| `Class` | `string` | The CSS class that will be rendered on the main wrapping element of the DropZone (`<div class="k-external-dropzone">`). Use it for [overriding the theme or applying custom styles]({%slug themes-override%}). |
71+
| `DragOverClass` | `string` | The CSS class that will be rendered on the main wrapping element of the DropZone when a file is dragged over it. Use it for [conditionally styling the component during a dragover action](https://demos.telerik.com/blazor-ui/dropzone/overview). |
72+
| `Width` | `string` | The width of the DropZone. Accepts a valid CSS value (see the [Dimensions article]({%slug common-features/dimensions%})). |
73+
| `Height` | `string` | The height of the DropZone. Accepts a valid CSS value (see the [Dimensions article]({%slug common-features/dimensions%})). |
74+
75+
## Next Steps
76+
77+
* [Using the DropZone Template for custom content]({%slug dropzone-template%})
78+
79+
## See Also
80+
81+
* [Live Demo: Blazor DropZone Overview and Key Features](https://demos.telerik.com/blazor-ui/dropzone/overview)

components/dropzone/template.md

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
---
2+
title: Template
3+
page_title: DropZone Content Template
4+
description: Learn more about how to modify the default content of the Telerik UI for Blazor DropZone by using its template and defining a custom layout.
5+
slug: dropzone-template
6+
tags: telerik,blazor,dropzone,external,drag,drop,file,template,custom,content
7+
published: True
8+
position: 5
9+
---
10+
11+
# DropZone Template
12+
13+
The DropZone allows you to customize the default rendering of its content by using a `Template`.
14+
15+
The `Template` is a `RenderFragment` and allows you to add whatever custom content is required such as simple text, HTML elements, or other components.
16+
17+
>caption Use Template to add custom content in the DropZone
18+
19+
````CSHTML
20+
<TelerikDropZone Id="@DropZoneId">
21+
<Template>
22+
<TelerikFontIcon Icon="@FontIcon.FileAdd" />
23+
<span>Drop files here</span>
24+
</Template>
25+
</TelerikDropZone>
26+
27+
<TelerikFileSelect DropZoneId="@DropZoneId" />
28+
29+
@code {
30+
private string DropZoneId => "my-dropzone";
31+
}
32+
````
33+
34+
## See Also
35+
36+
* [Live Demo: Implementing the Blazor DropZone Template](https://demos.telerik.com/blazor-ui/dropzone/template)

components/fileselect/events.md

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -12,38 +12,38 @@ position: 20
1212

1313
This article describes the events and event arguments of the Telerik FileSelect for Blazor:
1414

15-
* [OnSelect event](#onselect)
16-
* [OnRemove event](#onremove)
17-
* [FileSelectFileInfo class](#fileselectfileinfo)
15+
* [`OnSelect` event](#onselect)
16+
* [`OnRemove` event](#onremove)
17+
* [`FileSelectFileInfo` class](#fileselectfileinfo)
1818

1919
## FileSelectFileInfo
2020

21-
The FileSelect event handlers provide a [`FileSelectEventArgs` argument](/blazor-ui/api/Telerik.Blazor.Components.FileSelectEventArgs). It has a `Files` property, which is a `List<FileSelectFileInfo>`.
21+
The FileSelect event handlers provide a [`FileSelectEventArgs` argument](/blazor-ui/api/Telerik.Blazor.Components.FileSelectEventArgs). `FileSelectEventArgs` has a `Files` property, which is a `List<FileSelectFileInfo>` type.
2222

23-
The `FileSelectFileInfo` type contains these properties:
23+
The `FileSelectFileInfo` type contains the following properties:
2424

2525
@[template](/_contentTemplates/common/parameters-table-styles.md#table-layout)
2626

2727
Property | Type | Description
2828
---------|----------|---------
29-
`Id` | `string` | the unique file identifier
30-
`Name`|`string` | the file name
31-
`Size` |`long` | the file size in bytes
32-
`Extension` |`string` | the file extension
33-
`InvalidExtension` | `bool` | a boolean flag that shows if the file type is invalid
34-
`InvalidMinFileSize` | `bool` | a boolean flag that shows if file size is below the minimum
35-
`InvalidMaxFileSize` | `bool` | a boolean flag that shows if the file size exceeds the maximum
36-
`Stream`| `FileInfoStream` | a [System.IO.Stream](https://docs.microsoft.com/en-us/dotnet/api/system.io.stream) that can be used to load the file to memory, file system or other. Use it to **asynchronously** get the file contents as byte array.
29+
`Id` | `string` | The unique file identifier.
30+
`Name`|`string` | The file name.
31+
`Size` |`long` | The file size in bytes.
32+
`Extension` |`string` | The file extension.
33+
`InvalidExtension` | `bool` | A Boolean flag that shows if the file type is invalid.
34+
`InvalidMinFileSize` | `bool` | A Boolean flag that shows if file size is below the minimum.
35+
`InvalidMaxFileSize` | `bool` | A Boolean flag that shows if the file size exceeds the maximum.
36+
`Stream`| `FileInfoStream` | A [`System.IO.Stream`](https://docs.microsoft.com/en-us/dotnet/api/system.io.stream) that can be used to load the file to memory, file system, or other. Used for **asynchronously** getting the file contents as a byte array.
3737

38-
> Due to Blazor framework limitations, `FileInfoStream` does not support **synchronous** operations such as `Read`, `Seek`, `Flush` and `Write`. The methods exist, but will [throw an exception]({%slug fileselect-kb-stream-exception%}). A possible workaround is to copy the `FileInfoStream` **asynchronously** to another `Stream` via `CopyToAsync`. The `OnSelect` event example below demonstrates this.
38+
> Due to the Blazor framework limitations, `FileInfoStream` does not support **synchronous** operations such as `Read`, `Seek`, `Flush`, and `Write`. The methods exist, but will [throw an exception]({%slug fileselect-kb-stream-exception%}). A possible workaround is to copy the `FileInfoStream` **asynchronously** to another `Stream` with `CopyToAsync`, as demonstrated by the `OnSelect` event example below.
3939
4040
## OnSelect
4141

42-
The `OnSelect` fires when one or multiple files have been selected through the `Select files` button. Contains a list of fileInfo objects, allowing processing of the files.
42+
The `OnSelect` fires when one or more files have been selected. The selection of files is achieved either through the **Select files** button or by dropping the files anywhere in the component.
4343

44-
The event handler receives a [`FileSelectEventArgs` object](#fileselectfileinfo).
44+
The event handler receives a [`FileSelectEventArgs` object](#fileselectfileinfo), which contains a list of `FileInfo` objects that allow the processing of the files.
4545

46-
>caption Handle the OnSelect event of the FileSelect
46+
>caption Handling the `OnSelect` event of the FileSelect
4747
4848
````CSHTML
4949
@*Handle the OnSelect event of the FileSelect to access the selected files and upload them*@
@@ -89,7 +89,7 @@ The event handler receives a [`FileSelectEventArgs` object](#fileselectfileinfo)
8989
await using FileStream fs = new FileStream(path, FileMode.Create);
9090
await file.Stream.CopyToAsync(fs, Tokens[file.Id].Token);
9191
}
92-
92+
9393
private async Task ReadFile(FileSelectFileInfo file)
9494
{
9595
Tokens.Add(file.Id, new CancellationTokenSource());
@@ -103,11 +103,11 @@ The event handler receives a [`FileSelectEventArgs` object](#fileselectfileinfo)
103103

104104
## OnRemove
105105

106-
The `OnRemove` fires when a file has been removed from the list of selected files (by clicking the `x` icon or pressing `Del` key).
106+
The `OnRemove` fires when a file has been removed from the list of selected files either by clicking the **x** icon or by pressing the `Del` key.
107107

108108
The event handler receives a [`FileSelectEventArgs` object](#fileselectfileinfo). As the FileSelect component allows deleting one item at a time, the collection contains only one `FileSelectFileInfo` object (the deleted one).
109109

110-
>caption Handle the OnRemove event of the FileSelect
110+
>caption Handling the `OnRemove` event of the FileSelect
111111
112112
````CSHTML
113113
@*Handle the OnRemove event of the FileSelect to access and delete the uploaded files*@
@@ -143,7 +143,7 @@ The event handler receives a [`FileSelectEventArgs` object](#fileselectfileinfo)
143143
await Task.Delay(1);
144144
145145
var path = Path.Combine(HostingEnvironment?.WebRootPath, file.Name);
146-
146+
147147
// Remove the file from the file system
148148
File.Delete(path);
149149
}
@@ -157,6 +157,6 @@ The event handler receives a [`FileSelectEventArgs` object](#fileselectfileinfo)
157157

158158
## See Also
159159

160-
* [Live Demo: FileSelect Events](https://demos.telerik.com/blazor-ui/fileselect/events)
161-
* [FileSelect Overview]({%slug fileselect-overview%})
162-
* [FileSelect Validation]({%slug fileselect-validation%})
160+
* [Live Demo: Blazor FileSelect Events](https://demos.telerik.com/blazor-ui/fileselect/events)
161+
* [Telerik UI for Blazor FileSelect Overview]({%slug fileselect-overview%})
162+
* [Blazor FileSelect Validation]({%slug fileselect-validation%})

components/fileselect/overview.md

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,11 @@ position: 0
1010

1111
# Blazor FileSelect Overview
1212

13-
The <a href = "https://www.telerik.com/blazor-ui/fileselect" target="_blank">Blazor FileSelect component</a> helps users select one or multiple files from their local file system.
13+
The <a href = "https://www.telerik.com/blazor-ui/fileselect" target="_blank">Telerik UI for Blazor FileSelect component</a> helps users select one or more files from their local file system.
1414

15-
The Telerik FileSelect for Blazor provides a [Stream](https://docs.microsoft.com/en-us/dotnet/api/system.io.stream?view=net-6.0) for each selected file, so that you can manipulate the file in-memory or save (upload) it to the server file system.
15+
The Blazor FileSelect provides a [Stream](https://docs.microsoft.com/en-us/dotnet/api/system.io.stream?view=net-6.0) for each selected file, so that you can manipulate the file in-memory or save (upload) it to the server file system.
1616

17-
## Comparison to the Upload
17+
## FileSelect vs. Upload
1818

1919
@[template](/_contentTemplates/upload/notes.md#fileselect-upload-comparison)
2020

@@ -28,7 +28,7 @@ The Telerik FileSelect for Blazor provides a [Stream](https://docs.microsoft.com
2828

2929
Steps 2 and 3 are optional, but strongly recommended.
3030

31-
>caption Using FileSelect
31+
>caption Using the FileSelect
3232
3333
````CS
3434
<TelerikFileSelect AllowedExtensions="@AllowedExtensions"
@@ -59,6 +59,11 @@ In Blazor **Server** apps, the FileSelect uses the **SignalR WebSocket** to send
5959

6060
>tip The maximum file size supported by the framework up till .NET 5 was 2 GB and .NET 6 [removed this limit](https://github.com/dotnet/aspnetcore/pull/33900). While [Telerik UI for Blazor supports .NET version 3.1]({%slug system-requirements%}), the FileSelect component will allow maximum file size of 2 GB.
6161
62+
## Drag-and-Drop File Support
63+
64+
The FileSelect provides built-in file drag-and-drop support, which allows users to drag one or multiple files and drop them anywhere in the component. The [`OnSelect` event]({%slug fileselect-events%}#onselect) is raised upon dropping the file. You can handle this event to perform further actions with the selected file.
65+
66+
Additionally, you may define an external drop zone by using the [Telerik UI for Blazor DropZone component]({%slug dropzone-overview%}).
6267

6368
## Validation
6469

@@ -80,6 +85,7 @@ The following table lists the FileSelect parameters. Also check the [FileSelect
8085
| `AllowedExtensions` | `List<string>` | The list of allowed file types. The component will check if the selected files are compliant **after selection**. Compare with `Accept`. Read more at [Validation]({%slug fileselect-validation%}). |
8186
| `Capture` | `string` | The [`capture` HTML attribute](https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/capture) of the `<input type="file" />` element. It enables users to provide a file directly from their device camera. |
8287
| `Class` | `string` | Renders a custom CSS class to the `<div class="k-upload">` element. (The FileSelect reuses the Upload HTML rendering.) |
88+
| `DropZoneId` | `string` | The id that is used to connect the FileSelect to an external [DropZone]({%slug dropzone-overview%}). Assign a value matching the `Id` of the DropZone you are connecting the component with. |
8389
| `Enabled` | `bool`<br />(`true`) | Enables file selection. |
8490
| `Id` | `string` | Renders an `id` attribute to the `<input type="file" />` element. Can be used together with a `<label>`. |
8591
| `MinFileSize` | `int?` | Sets the minimum allowed file size in bytes. Read more at [Validation]({%slug fileselect-validation%}). |

0 commit comments

Comments
 (0)