@@ -1480,7 +1480,77 @@ For more information, see the following resources:
1480
1480
1481
1481
The `QuickGrid ` component is a Razor component for quickly and efficiently displaying data in tabular form . `QuickGrid ` provides a simple and convenient data grid component for common grid rendering scenarios and serves as a reference architecture and performance baseline for building data grid components . `QuickGrid ` is highly optimized and uses advanced techniques to achieve optimal rendering performance .
1482
1482
1483
- To get started with `QuickGrid `:
1483
+ To implement a `QuickGrid ` component :
1484
+
1485
+ * Specify tags for the `QuickGrid ` component in Razor markup (`< QuickGrid > .. .< / QuickGrid > `).
1486
+ * Name a queryable source of data for the grid . Use *** either *** of the following data sources :
1487
+ * `Items `: A nullable `IQueryable < TGridItem > `, where `TGridItem ` is the type of data represented by each row in the grid .
1488
+ * `ItemsProvider `: A callback that supplies data for the grid .
1489
+ * `Class `: An optional CSS class name . If provided , the class name is included in the `class ` attribute of the rendered table .
1490
+ * `Theme `: A theme name (default value : `default `). This affects which styling rules match the table .
1491
+ * `Virtualize `: If true , the grid is rendered with virtualization . This is normally used in conjunction with scrolling and causes the grid to fetch and render only the data around the current scroll viewport . This can greatly improve the performance when scrolling through large data sets. If you use `Virtualize`, you should supply a value for `ItemSize` and must ensure that every row renders with a constant height. Generally, it's preferable not to use `Virtualize` if the amount of data rendered is small or if you're using pagination.
1492
+ * `ItemSize `: Only applicable when using `Virtualize `. `ItemSize ` defines an expected height in pixels for each row , allowing the virtualization mechanism to fetch the correct number of items to match the display size and to ensure accurate scrolling .
1493
+ * `ItemKey `: Optionally defines a value for `@key ` on each rendered row . Typically , this is used to specify a unique identifier , such as a primary key value , for each data item . This allows the grid to preserve the association between row elements and data items based on their unique identifiers , even when the `TGridItem ` instances are replaced by new copies (for example , after a new query against the underlying data store ). If not set , the `@key ` is the `TGridItem ` instance .
1494
+ * `Pagination `: Optionally links this `QuickGrid {TGridItem }` instance with a `PaginationState ` model , causing the grid to fetch and render only the current page of data . This is normally used in conjunction with a `Paginator ` component or some other UI logic that displays and updates the supplied `PaginationState ` instance .
1495
+ * In the `QuickGrid ` child content (< xref :Microsoft .AspNetCore .Components .RenderFragment >), specify `PropertyColumn `s , which represent `QuickGrid {TGridItem }` columns whose cells display values :
1496
+ * `Property `: Defines the value to be displayed in this column 's cells.
1497
+ * `Format `: Optionally specifies a format string for the value . Using `Format ` requires the `TProp ` type to implement `IFormattable `.
1498
+ * `Sortable `: Indicates whether the data should be sortable by this column . The default value may vary according to the column type . For example , a `TemplateColumn {TGridItem }` is sortable by default if any `TemplateColumn {TGridItem }.SortBy ` parameter is specified .
1499
+ * `InitialSortDirection `: Indicates which direction to sort in if `IsDefaultSortColumn ` is `true `.
1500
+ * `IsDefaultSortColumn `: Indicates whether this column should be sorted by default .
1501
+ * `PlaceholderTemplate `: If specified , virtualized grids use this template to render cells whose data hasn 't been loaded.
1502
+
1503
+ For example , add the following component to render a grid .
1504
+
1505
+ `Pages / QuickGridExample .razor `:
1506
+
1507
+ ```razor
1508
+ @page " /quickgrid-example"
1509
+
1510
+ < QuickGrid Items = " @people" >
1511
+ < PropertyColumn Property = " @(p => p.PersonId)" Sortable = " true" / >
1512
+ < PropertyColumn Property = " @(p => p.Name)" Sortable = " true" / >
1513
+ < PropertyColumn Property = " @(p => p.PromotionDate)" Format = " yyyy-MM-dd" Sortable = " true" / >
1514
+ < / QuickGrid >
1515
+
1516
+ @code {
1517
+ private record Person (int PersonId , string Name , DateOnly PromotionDate );
1518
+
1519
+ private IQueryable < Person > people = new []
1520
+ {
1521
+ new Person (10895 , " Jean Martin" , new DateOnly (1985 , 3 , 16 )),
1522
+ new Person (10944 , " António Langa" , new DateOnly (1991 , 12 , 1 )),
1523
+ new Person (11203 , " Julie Smith" , new DateOnly (1958 , 10 , 10 )),
1524
+ new Person (11205 , " Nur Sari" , new DateOnly (1922 , 4 , 27 )),
1525
+ new Person (11898 , " Jose Hernandez" , new DateOnly (2011 , 5 , 3 )),
1526
+ new Person (12130 , " Kenji Sato" , new DateOnly (2004 , 1 , 9 )),
1527
+ }.AsQueryable ();
1528
+ }
1529
+ ```
1530
+
1531
+ For an example that uses an < xref : System .Linq .IQueryable > with Entity Framework Core as the queryable data source , see the [`SampleQuickGridComponent ` component in the ASP .NET Core Basic Test App (`dotnet / aspnetcore ` GitHub repository )](https :// github.com/dotnet/aspnetcore/blob/main/src/Components/test/testassets/BasicTestApp/QuickGridTest/SampleQuickGridComponent.razor).
1532
+
1533
+ [! INCLUDE [](~ / includes / aspnetcore - repo - ref - source - links .md )]
1534
+
1535
+ To use EF Core as the data source :
1536
+
1537
+ * Add a package reference to the app for the [`Microsoft .AspNetCore .Components .QuickGrid .EntityFrameworkAdapter `](https :// www.nuget.org/packages/Microsoft.AspNetCore.Components.QuickGrid.EntityFrameworkAdapter) package.
1538
+
1539
+ [! INCLUDE [](~ / includes / package - reference .md )]
1540
+
1541
+ * Call `AddQuickGridEntityFrameworkAdapter ` on the service collection in `Startup .ConfigureServices ` of `Startup .cs ` (Blazor Server ) or `Program .cs ` (Blazor WebAssembly ) to register an EF - aware implementation of `IAsyncQueryExecutor `.
1542
+
1543
+ * Blazor Server :
1544
+
1545
+ ```csharp
1546
+ services .AddQuickGridEntityFrameworkAdapter ();
1547
+ ```
1548
+
1549
+ * Blazor WebAssembly :
1550
+
1551
+ ```csharp
1552
+ builder .Services .AddQuickGridEntityFrameworkAdapter ();
1553
+ ```
1484
1554
1485
1555
::: moniker - end
1486
1556
@@ -1490,44 +1560,44 @@ The `QuickGrid` component is an experimental Razor component for quickly and eff
1490
1560
1491
1561
To get started with `QuickGrid `:
1492
1562
1493
- 1 . Add package reference for [`Microsoft .AspNetCore .Components .QuickGrid `](https :// www.nuget.org/packages/Microsoft.AspNetCore.Components.QuickGrid). If using the .NET CLI to add the package reference, include the `--prerelease` option when you execute the [`dotnet add package` command](/dotnet/core/tools/dotnet-add-package).
1563
+ Add package reference for [`Microsoft .AspNetCore .Components .QuickGrid `](https :// www.nuget.org/packages/Microsoft.AspNetCore.Components.QuickGrid). If using the .NET CLI to add the package reference, include the `--prerelease` option when you execute the [`dotnet add package` command](/dotnet/core/tools/dotnet-add-package).
1494
1564
1495
- [! INCLUDE [](~ / includes / package - reference .md )]
1565
+ [! INCLUDE [](~ / includes / package - reference .md )]
1496
1566
1497
- ::: moniker - end
1567
+ Add the following component to render a grid .
1498
1568
1499
- ::: moniker range = " >= aspnetcore-7.0 "
1569
+ ` Pages / QuickGridExample . razor ` :
1500
1570
1501
- 1 . Add the following component to render a grid .
1571
+ ```razor
1572
+ @page " /quickgrid-example"
1573
+ @using Microsoft .AspNetCore .Components .QuickGrid
1502
1574
1503
- `Pages / QuickGridExample .razor `:
1575
+ < QuickGrid Items = " @people" >
1576
+ < PropertyColumn Property = " @(p => p.PersonId)" Sortable = " true" / >
1577
+ < PropertyColumn Property = " @(p => p.Name)" Sortable = " true" / >
1578
+ < PropertyColumn Property = " @(p => p.PromotionDate)" Format = " yyyy-MM-dd" Sortable = " true" / >
1579
+ < / QuickGrid >
1504
1580
1505
- ```razor
1506
- @page " /quickgrid-example"
1507
- @using Microsoft .AspNetCore .Components .QuickGrid
1581
+ @code {
1582
+ private record Person (int PersonId , string Name , DateOnly PromotionDate );
1508
1583
1509
- < QuickGrid Items = " @people" >
1510
- < PropertyColumn Property = " @(p => p.PersonId)" Sortable = " true" / >
1511
- < PropertyColumn Property = " @(p => p.Name)" Sortable = " true" / >
1512
- < PropertyColumn Property = " @(p => p.BirthDate)" Format = " yyyy-MM-dd" Sortable = " true" / >
1513
- < / QuickGrid >
1584
+ private IQueryable < Person > people = new []
1585
+ {
1586
+ new Person (10895 , " Jean Martin" , new DateOnly (1985 , 3 , 16 )),
1587
+ new Person (10944 , " António Langa" , new DateOnly (1991 , 12 , 1 )),
1588
+ new Person (11203 , " Julie Smith" , new DateOnly (1958 , 10 , 10 )),
1589
+ new Person (11205 , " Nur Sari" , new DateOnly (1922 , 4 , 27 )),
1590
+ new Person (11898 , " Jose Hernandez" , new DateOnly (2011 , 5 , 3 )),
1591
+ new Person (12130 , " Kenji Sato" , new DateOnly (2004 , 1 , 9 )),
1592
+ }.AsQueryable ();
1593
+ }
1594
+ ```
1514
1595
1515
- @code {
1516
- private record Person (int PersonId , string Name , DateOnly BirthDate );
1596
+ ::: moniker - end
1517
1597
1518
- private IQueryable < Person > people = new []
1519
- {
1520
- new Person (10895 , " Jean Martin" , new DateOnly (1985 , 3 , 16 )),
1521
- new Person (10944 , " António Langa" , new DateOnly (1991 , 12 , 1 )),
1522
- new Person (11203 , " Julie Smith" , new DateOnly (1958 , 10 , 10 )),
1523
- new Person (11205 , " Nur Sari" , new DateOnly (1922 , 4 , 27 )),
1524
- new Person (11898 , " Jose Hernandez" , new DateOnly (2011 , 5 , 3 )),
1525
- new Person (12130 , " Kenji Sato" , new DateOnly (2004 , 1 , 9 )),
1526
- }.AsQueryable ();
1527
- }
1528
- ```
1598
+ ::: moniker range = " >= aspnetcore-7.0"
1529
1599
1530
- 1 . Access the component in a browser at the relative path `/ quickgrid - example `.
1600
+ Access the component in a browser at the relative path `/ quickgrid - example `.
1531
1601
1532
1602
For various `QuickGrid ` demonstrations , see the [** QuickGrid for Blazor ** app ](https :// aspnet.github.io/quickgridsamples/). The demo site is built using Blazor WebAssembly and is hosted on GitHub Pages. The site loads fast thanks to static prerendering using the community-maintained [`BlazorWasmPrerendering.Build` GitHub project](https://github.com/jsakamoto/BlazorWasmPreRendering.Build).
1533
1603
@@ -1538,7 +1608,7 @@ There aren't current plans to extend `QuickGrid` with features that full-blown c
1538
1608
::: moniker range = " >= aspnetcore-7.0 < aspnetcore-8.0"
1539
1609
1540
1610
> [! WARNING ]
1541
- > The `QuickGrid ` component is in preview . You 're welcome to use it in production if it meets your needs , but it isn 't officially supported and may change in future releases .
1611
+ > The `QuickGrid ` component is in preview for ASP . NET Core 7. x . You 're welcome to use it in production if it meets your needs , but it isn 't officially supported until ASP.NET Core 8.0 or later .
1542
1612
1543
1613
::: moniker - end
1544
1614
0 commit comments