Loading...
Loading...
Compare original and translation side by side
DownloadFilesAsync(selectedItems)GetSelectedFiles()ShowThumbnailDownloadFilesAsync(selectedItems)GetSelectedFiles()ShowThumbnail@using Syncfusion.Blazor.FileManager
<SfFileManager TValue="FileManagerDirectoryContent">
<FileManagerAjaxSettings Url="/api/FileManager/FileOperations"
UploadUrl="/api/FileManager/Upload"
DownloadUrl="/api/FileManager/Download"
GetImageUrl="/api/FileManager/GetImage">
</FileManagerAjaxSettings>
</SfFileManager>using Syncfusion.Blazor;
builder.Services.AddSyncfusionBlazor();
builder.Services.AddControllers();
app.UseRouting();
app.MapControllers();<head>
<link href="_content/Syncfusion.Blazor.Themes/bootstrap5.css" rel="stylesheet" />
</head>
<body>
<script src="_content/Syncfusion.Blazor.Core/scripts/syncfusion-blazor.min.js"></script>
</body>@using Syncfusion.Blazor.FileManager
<SfFileManager TValue="FileManagerDirectoryContent">
<FileManagerAjaxSettings Url="/api/FileManager/FileOperations"
UploadUrl="/api/FileManager/Upload"
DownloadUrl="/api/FileManager/Download"
GetImageUrl="/api/FileManager/GetImage">
</FileManagerAjaxSettings>
</SfFileManager>using Syncfusion.Blazor;
builder.Services.AddSyncfusionBlazor();
builder.Services.AddControllers();
app.UseRouting();
app.MapControllers();<head>
<link href="_content/Syncfusion.Blazor.Themes/bootstrap5.css" rel="stylesheet" />
</head>
<body>
<script src="_content/Syncfusion.Blazor.Core/scripts/syncfusion-blazor.min.js"></script>
</body><SfFileManager TValue="FileManagerDirectoryContent">
<FileManagerEvents TValue="FileManagerDirectoryContent" OnRead="OnReadAsync"></FileManagerEvents>
</SfFileManager>
@code {
private async Task OnReadAsync(ReadEventArgs<FileManagerDirectoryContent> args)
{
// Load data from your service
var response = await YourService.GetFilesAsync(args.Path);
args.Response = response;
}
}<SfFileManager TValue="FileManagerDirectoryContent">
<FileManagerEvents TValue="FileManagerDirectoryContent" OnRead="OnReadAsync"></FileManagerEvents>
</SfFileManager>
@code {
private async Task OnReadAsync(ReadEventArgs<FileManagerDirectoryContent> args)
{
// 从服务加载数据
var response = await YourService.GetFilesAsync(args.Path);
args.Response = response;
}
}<SfFileManager TValue="FileManagerDirectoryContent">
<FileManagerAjaxSettings Url="/api/AzureProvider/FileOperations"
UploadUrl="/api/AzureProvider/Upload"
DownloadUrl="/api/AzureProvider/Download"
GetImageUrl="/api/AzureProvider/GetImage">
</FileManagerAjaxSettings>
</SfFileManager><SfFileManager TValue="FileManagerDirectoryContent">
<FileManagerAjaxSettings Url="/api/AzureProvider/FileOperations"
UploadUrl="/api/AzureProvider/Upload"
DownloadUrl="/api/AzureProvider/Download"
GetImageUrl="/api/AzureProvider/GetImage">
</FileManagerAjaxSettings>
</SfFileManager>@ref="FileManager"
<SfButton OnClick="DownloadFiles">Download Selected</SfButton>
<SfFileManager @ref="FileManager" TValue="FileManagerDirectoryContent">
<!-- configuration -->
</SfFileManager>
@code {
SfFileManager<FileManagerDirectoryContent> FileManager;
public async Task DownloadFiles()
{
await FileManager.DownloadFilesAsync(FileManager.SelectedItems);
}
}@ref="FileManager"
<SfButton OnClick="DownloadFiles">下载已选文件</SfButton>
<SfFileManager @ref="FileManager" TValue="FileManagerDirectoryContent">
<!-- 配置内容 -->
</SfFileManager>
@code {
SfFileManager<FileManagerDirectoryContent> FileManager;
public async Task DownloadFiles()
{
await FileManager.DownloadFilesAsync(FileManager.SelectedItems);
}
}<SfFileManager TValue="FileManagerDirectoryContent">
<FileManagerEvents TValue="FileManagerDirectoryContent"
ItemsDeleting="OnItemsDeleting"
BeforeDownload="OnBeforeDownload">
</FileManagerEvents>
</SfFileManager>
@code {
public async Task OnItemsDeleting(ItemsDeleteEventArgs<FileManagerDirectoryContent> args)
{
// Validate before delete
if (args.Files.Count > 10)
{
args.Cancel = true;
}
}
public void OnBeforeDownload(BeforeDownloadEventArgs<FileManagerDirectoryContent> args)
{
// Custom download logic
}
}<SfFileManager TValue="FileManagerDirectoryContent">
<FileManagerEvents TValue="FileManagerDirectoryContent"
ItemsDeleting="OnItemsDeleting"
BeforeDownload="OnBeforeDownload">
</FileManagerEvents>
</SfFileManager>
@code {
public async Task OnItemsDeleting(ItemsDeleteEventArgs<FileManagerDirectoryContent> args)
{
// 删除前验证
if (args.Files.Count > 10)
{
args.Cancel = true;
}
}
public void OnBeforeDownload(BeforeDownloadEventArgs<FileManagerDirectoryContent> args)
{
// 自定义下载逻辑
}
}| Property | Type | Default | Purpose |
|---|---|---|---|
| Generic | FileManagerDirectoryContent | Data model type |
| string | - | AJAX endpoint for file operations |
| string | - | Upload endpoint |
| string | - | Download endpoint |
| string | - | Image preview endpoint |
| string | Name | Sort field (Name, Size, DateModified, DateCreated) |
| SortOrder | Ascending | Sort direction (None, Ascending, Descending) |
| ViewType | LargeIcons | Display mode (Details, LargeIcons) |
| bool | false | Enable virtual scrolling for large datasets |
| string | - | Root directory path |
| bool | false | Show hidden files and folders |
| bool | false | Enable pagination support |
| int | 100 | Number of items per page |
| bool | false | Allow directory upload |
| 属性 | 类型 | 默认值 | 用途 |
|---|---|---|---|
| 泛型 | FileManagerDirectoryContent | 数据模型类型 |
| 字符串 | - | 文件操作的AJAX端点 |
| 字符串 | - | 上传端点 |
| 字符串 | - | 下载端点 |
| 字符串 | - | 图片预览端点 |
| 字符串 | Name | 排序字段(名称、大小、修改日期、创建日期) |
| SortOrder | Ascending | 排序方向(无、升序、降序) |
| ViewType | LargeIcons | 展示模式(详情、大图标) |
| 布尔值 | false | 为大规模数据集启用虚拟滚动 |
| 字符串 | - | 根目录路径 |
| 布尔值 | false | 显示隐藏文件和文件夹 |
| 布尔值 | false | 启用分页支持 |
| 整数 | 100 | 每页展示项数 |
| 布尔值 | false | 允许目录上传 |