RadzenDataGrid does not reload after data property is updated or changed

I’m having a problem that I can’t get my head around. I’ve read numerous articles online and nobody appears to have come across any solution which works for me.

Goal

I want to display a file selector, upon selecting a file it should show the selected files within a RadzenDataGrid.

The Problem

After selecting the files the User Interface isn’t updated. I can’t quite tell whether Radzen, Blazor (or I) am at fault, but I can confirm that the fileGrid.Data property is indeed being updated.

I should also point out I have tried implementing StateHasChanged() to no avail. It appears fileGrid.Reload() calls this anyway. Further to this I’ve also tried InvokeAsync(StateHasChanged()) with no luck either.

Any help would be appreciated.

Here’s the .razor page at hand.

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<code><head>
<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Material+Symbols+Outlined:opsz,wght,FILL,GRAD@24,400,0,0" />
</head>
<div>
<InputFile id="fileInput" class="hidden" accept="@Accept" OnChange="HandleFileChange" multiple />
<RadzenText TextStyle="TextStyle.Overline">@Text</RadzenText>
<label for="fileInput">
<span class="btn material-symbols-outlined">
Add
</span>
</label>
<RadzenDataGrid @ref="fileGrid" Data=files PageSize="10">
<Columns>
<RadzenDataGrid TItem="IBrowserFile" Property="Name" Title="Name" />
<RadzenDataGrid TItem="IBrowserFile" Property="Size" Title="Size" />
<RadzenDataGrid TItem="IBrowserFile">
<Template Context="item">
<RadzenIcon class="action-icon float-right" Icon="delete_forever" @onclick="@(() => RemoveFile(item))" />
</Template>
</RadzenDataGrid>
</Columns>
</RadzenDataGrid>
</div>
<Toast @ref="toast" />
<style>
.hidden {
display: none;
}
.btn {
cursor: pointer;
padding: 0;
margin: 0;
}
</style>
@code {
[Parameter]
public string Accept { get; set; } = "*";
[Parameter]
public string Text { get; set; } = "Files";
[Parameter]
public EventCallback<List<IBrowserFile>> FilesChanged { get; set; }
List<IBrowserFile> files { get; set; } = new();
Toast toast;
RadzenDataGrid<IBrowserFile> fileGrid;
const int maxFileSizeMb = 10;
private async Task HandleFileChange(InputFileChangeEventArgs eventArgs)
{
List<IBrowserFile> validFiles = new();
foreach (var file in eventArgs.GetMultipleFiles())
{
if (ValidateSize(file))
validFiles.Add(file);
else
toast.Show($"{file.Name} exceeds the file limit of {maxFileSizeMb}mb");
}
files = validFiles;
// Notify the UI to update
if (fileGrid != null)
{
await fileGrid.Reload();
}
}
private bool ValidateSize(IBrowserFile file) => file.Size < maxFileSizeMb * 1024 * 1024;
private void RemoveFile(IBrowserFile file)
{
files.Remove(file);
// Reload the data grid
fileGrid?.Reload();
}
}
</code>
<code><head> <link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Material+Symbols+Outlined:opsz,wght,FILL,GRAD@24,400,0,0" /> </head> <div> <InputFile id="fileInput" class="hidden" accept="@Accept" OnChange="HandleFileChange" multiple /> <RadzenText TextStyle="TextStyle.Overline">@Text</RadzenText> <label for="fileInput"> <span class="btn material-symbols-outlined"> Add </span> </label> <RadzenDataGrid @ref="fileGrid" Data=files PageSize="10"> <Columns> <RadzenDataGrid TItem="IBrowserFile" Property="Name" Title="Name" /> <RadzenDataGrid TItem="IBrowserFile" Property="Size" Title="Size" /> <RadzenDataGrid TItem="IBrowserFile"> <Template Context="item"> <RadzenIcon class="action-icon float-right" Icon="delete_forever" @onclick="@(() => RemoveFile(item))" /> </Template> </RadzenDataGrid> </Columns> </RadzenDataGrid> </div> <Toast @ref="toast" /> <style> .hidden { display: none; } .btn { cursor: pointer; padding: 0; margin: 0; } </style> @code { [Parameter] public string Accept { get; set; } = "*"; [Parameter] public string Text { get; set; } = "Files"; [Parameter] public EventCallback<List<IBrowserFile>> FilesChanged { get; set; } List<IBrowserFile> files { get; set; } = new(); Toast toast; RadzenDataGrid<IBrowserFile> fileGrid; const int maxFileSizeMb = 10; private async Task HandleFileChange(InputFileChangeEventArgs eventArgs) { List<IBrowserFile> validFiles = new(); foreach (var file in eventArgs.GetMultipleFiles()) { if (ValidateSize(file)) validFiles.Add(file); else toast.Show($"{file.Name} exceeds the file limit of {maxFileSizeMb}mb"); } files = validFiles; // Notify the UI to update if (fileGrid != null) { await fileGrid.Reload(); } } private bool ValidateSize(IBrowserFile file) => file.Size < maxFileSizeMb * 1024 * 1024; private void RemoveFile(IBrowserFile file) { files.Remove(file); // Reload the data grid fileGrid?.Reload(); } } </code>
<head>
    <link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Material+Symbols+Outlined:opsz,wght,FILL,GRAD@24,400,0,0" />
</head>
<div>
    <InputFile id="fileInput" class="hidden" accept="@Accept" OnChange="HandleFileChange" multiple />
    <RadzenText TextStyle="TextStyle.Overline">@Text</RadzenText>
    <label for="fileInput">
        <span class="btn material-symbols-outlined">
            Add
        </span>
    </label>
    <RadzenDataGrid @ref="fileGrid" Data=files PageSize="10">
        <Columns>
            <RadzenDataGrid TItem="IBrowserFile" Property="Name" Title="Name" />
            <RadzenDataGrid TItem="IBrowserFile" Property="Size" Title="Size" />
            <RadzenDataGrid TItem="IBrowserFile">
                <Template Context="item">
                    <RadzenIcon class="action-icon float-right" Icon="delete_forever" @onclick="@(() => RemoveFile(item))" />
                </Template>
            </RadzenDataGrid>
        </Columns>
    </RadzenDataGrid>
</div>
<Toast @ref="toast" />

<style>
    .hidden {
        display: none;
    }

    .btn {
        cursor: pointer;
        padding: 0;
        margin: 0;
    }
</style>

@code {
    [Parameter]
    public string Accept { get; set; } = "*";

    [Parameter]
    public string Text { get; set; } = "Files";

    [Parameter]
    public EventCallback<List<IBrowserFile>> FilesChanged { get; set; }

    List<IBrowserFile> files { get; set; } = new();
    Toast toast;
    RadzenDataGrid<IBrowserFile> fileGrid;

    const int maxFileSizeMb = 10;

    private async Task HandleFileChange(InputFileChangeEventArgs eventArgs)
    {
        List<IBrowserFile> validFiles = new();

        foreach (var file in eventArgs.GetMultipleFiles())
        {
            if (ValidateSize(file))
                validFiles.Add(file);
            else
                toast.Show($"{file.Name} exceeds the file limit of {maxFileSizeMb}mb");
        }

        files = validFiles;

        // Notify the UI to update
        if (fileGrid != null)
        {
            await fileGrid.Reload();
        }
    }

    private bool ValidateSize(IBrowserFile file) => file.Size < maxFileSizeMb * 1024 * 1024;

    private void RemoveFile(IBrowserFile file)
    {
        files.Remove(file);
        // Reload the data grid
        fileGrid?.Reload();
    }
}

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật