Skip to content

Conversation

@miguelhasse
Copy link
Contributor

@miguelhasse miguelhasse commented Sep 30, 2025

Pull Request

📖 Description

This feature introduces two visual enhancements to the DataGrid component while asynchronously loading items from an IQueryable data source:

  1. The 'Loading' state flag is always set to true when requesting items on first time load (or while no items have yet been loaded) providing better visual feedback for users (avoiding empty item messages before loading).
  2. Exceptions that occur when asynchronously requesting items can the caught, depending on the filter parameter 'HandleLoadingError', and displayed in the body of the DataGrid. The exception error rendering can be customized using 'ErrorContent' template.

👩‍💻 Reviewer Notes

A working sample of the 'Loading' state flag feature can be seen in the following samples:

These same samples can be used to see a working sample for the error handling feature by forcing data source connection errors.

✅ Checklist

General

  • I have added tests for my changes.
  • I have tested my changes.
  • I have updated the project documentation to reflect my changes.
  • I have read the CONTRIBUTING documentation and followed the standards for this project.

Component-specific

  • I have added a new component
  • I have added Unit Tests for my new component
  • I have modified an existing component
  • I have validated the Unit Tests for an existing component

@vnbaaij vnbaaij added this to the v4.12.2 milestone Sep 30, 2025
@vnbaaij
Copy link
Collaborator

vnbaaij commented Sep 30, 2025

The FluentDataGrid_With_Empty_Items_Stays_Loading_Until_Changed test is failing with this PR applied.

We cannot just alter the test to make it pass with the new code. That would mean we introduce a breaking change (albeit a small one)

Before (our code):
image

After (your PR code):
image

Please review the PR and make the necessary changes so all tests pass unaltered. Thanks

@miguelhasse
Copy link
Contributor Author

@vnbaaij I'll check the failing unit test and apply required fixes. Thanks

@miguelhasse miguelhasse requested a review from dvoituron October 2, 2025 09:04
@vnbaaij
Copy link
Collaborator

vnbaaij commented Oct 2, 2025

@miguelhasse now there are 3 failed Unit Tests...

image

Use this code in the IssueTester to verify the result with current version:

<FluentDataGrid @ref="Grid" Items="@Items.AsQueryable()" Loading="loading">
	<EmptyContent><p id="empty-content">empty content</p></EmptyContent>
	<LoadingContent><p id="loading-content">loading content</p></LoadingContent>
	<ChildContent>
		<PropertyColumn Property="@(i => i.Name)" />
	</ChildContent>
</FluentDataGrid>

<br />
<FluentButton OnClick="ToggleLoading">Toggle Loading</FluentButton>

@code {
	private FluentDataGrid<Customer> Grid { get; set; } = null!;
	private bool loading = true;
	private IEnumerable<Customer> Items = Array.Empty<Customer>();

	// Sample data...
	private IEnumerable<Customer> GetCustomers()
	{
		yield return new Customer(1, "Denis Voituron");
		yield return new Customer(2, "Vincent Baaij");
		yield return new Customer(3, "Bill Gates");
	}

	private record Customer(int Id, string Name);

	private async Task ToggleLoading()
	{
		// up untill now it shows loading content
		loading = false;

		// now it shows empty content

		await Task.Delay(2000);
		Items = GetCustomers();
		// now it shows data
	}
}

@dvoituron dvoituron merged commit 696f10d into microsoft:dev Oct 2, 2025
2 checks passed
@dvoituron
Copy link
Collaborator

@vnbaaij Could this new feature be added to v5?

vnbaaij added a commit that referenced this pull request Oct 6, 2025
vnbaaij added a commit that referenced this pull request Oct 8, 2025
* Implement #4036

* Implement #4070

* Implement #4112

* Implement #4116

* Add extra test. Brings back code coverage to 100% for Row and Cell

* Implement #4172

* Implement #4177

* - Remove NoTabbing parameter (not being used)
- Exclude ErrorContent from code coverage
- Add (partial) ErrorContentTest, add IsFixed test, update tests

* Implement #4178

Related Work Items: #41

* Add CustomIcon and IconsExtensions + tests

---------

Co-authored-by: Denis Voituron <dvoituron@outlook.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants