# FluentDataGrid `FluentDataGrid` is a strongly-typed generic component for displaying tabular data. ## Basic Usage ```razor Edit ``` **Critical**: Columns are child components, NOT properties. Use `PropertyColumn`, `TemplateColumn`, and `SelectColumn` within the grid. ## Column Types ### PropertyColumn Binds to a property expression. Auto-derives title from property name or `[Display]` attribute. ```razor ``` Parameters: `Property` (required), `Format`, `Title`, `Sortable`, `SortBy`, `Comparer`, `IsDefaultSortColumn`, `InitialSortDirection`, `Class`, `Tooltip`. ### TemplateColumn Full custom rendering via render fragment. `context` is the `TGridItem`. ```razor @(context.IsActive ? "Active" : "Inactive") ``` ### SelectColumn Checkbox selection column. ```razor ``` Modes: `DataGridSelectMode.Single`, `DataGridSelectMode.Multiple`. ## Data Sources Two mutually exclusive approaches: ### In-memory (IQueryable) ```razor ... ``` ### Server-side / Custom (ItemsProvider) ```razor ... @code { private GridItemsProvider peopleProvider = async request => { var result = await PeopleService.GetPeopleAsync( request.StartIndex, request.Count ?? 50, request.GetSortByProperties().FirstOrDefault()); return GridItemsProviderResult.From(result.Items, result.TotalCount); }; } ``` ### EF Core Adapter ```csharp // Program.cs builder.Services.AddDataGridEntityFrameworkAdapter(); ``` ```razor ... ``` ## Pagination ```razor ... @code { private PaginationState pagination = new() { ItemsPerPage = 10 }; } ``` ## Virtualization For large datasets, enable virtualization: ```razor ... ``` `ItemSize` is the estimated row height in pixels (default varies). Important for scroll position calculations. ## Key Parameters | Parameter | Type | Description | |---|---|---| | `Items` | `IQueryable?` | In-memory data source | | `ItemsProvider` | `GridItemsProvider?` | Async data provider | | `Pagination` | `PaginationState?` | Pagination state | | `Virtualize` | `bool` | Enable virtualization | | `ItemSize` | `float` | Estimated row height (px) | | `ItemKey` | `Func?` | Stable key for `@key` | | `ResizableColumns` | `bool` | Enable column resize | | `HeaderCellAsButtonWithMenu` | `bool` | Sortable header UI | | `GridTemplateColumns` | `string?` | CSS grid-template-columns | | `Loading` | `bool` | Show loading indicator | | `ShowHover` | `bool` | Highlight rows on hover | | `OnRowClick` | `EventCallback>` | Row click handler | | `OnRowDoubleClick` | `EventCallback>` | Row double-click handler | | `OnRowFocus` | `EventCallback>` | Row focus handler | ## Sorting ```razor ``` Or with a custom sort: ```razor @context.LastName, @context.FirstName ```