Implementing Syncfusion Blazor DataGrid
The Syncfusion Blazor DataGrid (SfGrid<TValue>) is a high-performance, feature-rich component for displaying and manipulating tabular data. It supports data binding, sorting, filtering, grouping, paging, editing, selection, aggregates, export, virtual/infinite scrolling, templates, and more.
NuGet: Syncfusion.Blazor.Grid + Syncfusion.Blazor.Themes
Namespace: Syncfusion.Blazor.Grids
When to Use This Skill
Use this skill when you need to:
- Set up and configure a DataGrid in Blazor Server, WebAssembly, Web App, or MAUI
- Bind local or remote data (OData, HTTP, SfDataManager)
- Configure columns (type, format, template, frozen, reorder, resize, chooser)
- Implement sorting, filtering (FilterBar/Menu/Excel/CheckBox), or searching
- Enable grouping with lazy load or caption templates
- Configure paging with custom templates or SfPager
- Set up virtual scrolling, infinite scrolling for large datasets
- Implement editing (Normal/Dialog/Batch/Command column) with validation
- Configure selection (row, cell, checkbox) with programmatic control
- Use clipboard copy, AutoFill, or Paste features
- Add aggregates (footer, group, caption, reactive)
- Use row/column templates, detail template, row drag-drop
- Configure toolbar, context menu, column menu, column chooser
- Export data to Excel or PDF
- Manage print functionality
- Optimize performance (SetRowDataAsync, PreventRender)
- Handle DataGrid events
- Manage state persistence (EnablePersistence)
- Customize styling and appearance
- Enable adaptive UI for mobile/responsive layouts
🔒 Mandatory Key Rules
These rules govern how this skill MUST behave. They are mandatory and must be strictly followed.
1. Purpose and Responsibility
Your responsibility is to interpret any natural‑language user request and provide:
- Accurate
- Complete
- Validated
information about all supported aspects of the Syncfusion Blazor DataGrid, including:
- Public APIs
- Properties
- Events
- Features
- Behaviors
2. Accuracy and API Compliance
The Skill MUST:
- Use only officially supported Syncfusion DataGrid features.
- NEVER invent APIs, methods, properties, events, behaviors, or future features.
- NEVER provide unsupported or hypothetical code samples.
- ALWAYS follow official Syncfusion component design patterns.
If a feature is not supported:
- Clearly state the limitation.
- Suggest a supported alternative when possible.
3. Interpreting Natural-Language Requests
When user requests are incomplete:
- Infer reasonable assumptions using official Grid best practices.
- Fill missing gaps with accurate and relevant information.
- Request clarification only when essential.
4. Response Quality Requirements
Every response MUST:
- Be technically accurate
- Be complete and well‑structured
- Include required dependencies and configuration notes
- Follow real, documented Syncfusion API behavior
- Avoid contradictions or ambiguity
5. Handling Unsupported User Requests
If the user asks for an unsupported capability:
- Explicitly state that it is not supported
- Suggest official alternatives or valid workarounds
- NEVER simulate or fabricate impossible functionality
6. Design Pattern Enforcement
The Skill MUST follow Syncfusion official patterns, including:
- Correct component structure (
SfGrid, GridColumn, GridEditSettings, etc.)
- Proper async event and API usage
- Valid configuration properties and enums
- Supported data‑binding approaches
- Real event patterns and names
7. Quality, Completeness & Reliability
The Skill MUST:
- Use only validated and real Grid capabilities
- Provide actionable and implementation‑ready guidance
- Ensure clarity so users can follow without guesswork
- Maintain clean, readable, and professional formatting
8. No-Hallucination Safeguard
The Skill MUST NOT:
- Invent non‑existent APIs or behavior
- Suggest unsupported modes, features, or configuration
- Provide incorrect, misleading, or unverifiable code
- Describe undocumented internal behavior
If unsure:
- Ask for clarification OR
- Clearly state the limitation
9. Event Name Verification Requirement
CRITICAL: Event names MUST be verified against references/events.md BEFORE providing code examples. All grid events MUST be defined inside the <GridEvents> component
Common Mistakes to Avoid:
- ❌
OnSortChange - Does NOT exist. Use Sorting, Sorted instead
- ❌
OnFilterChange - Does NOT exist. Use Filtering, Filtered instead
- ❌
OnPageChange - Does NOT exist. Use PageChanging, PageChanged instead
- ❌
OnGroupChange - Does NOT exist. Use Grouping, Grouped instead
Rule: ALWAYS cross-reference references/events.md for:
- Exact event names (case-sensitive)
- Event argument types
- Whether events are cancelable
- When they fire (before/after operation)
Verification Checklist Before Providing Event Code:
- Check if event name exists in
references/events.md
- Verify the correct
EventArgs type
- Confirm
Cancelable status (✅ or ❌)
- Test against actual Syncfusion documentation
- Never assume naming conventions (e.g.,
On prefix, Change suffix)
Strict Rules for Grid Events
1. Event Handlers MUST be in <GridEvents> Component
- ✅ Define ALL event handlers inside
<GridEvents TValue="YourType">
- ✅ Use the exact event names as properties (e.g.,
DataBound, RowSelecting, Grouped)
- ❌ DO NOT use
@onEventName syntax on <SfGrid>
- ❌ DO NOT define event handlers on any root element
2. Correct Event Handler Signatures
- ✅ Use
async Task for event handlers
- ✅ Event handlers may have specific parameter types (e.g.,
GridEventArgs, RowSelectEventArgs)
- ✅ Some events have no parameters (e.g.,
DataBound(), Created())
- ❌ Do not use synchronous
void methods for async operations
3. API Method Calls MUST NOT be in Lifecycle Events
- ❌ DO NOT call API methods in
OnInitialized()
- ❌ DO NOT call API methods in
OnAfterRenderAsync()
- ❌ DO NOT call API methods in
OnParametersSet()
- ✅ ONLY call API methods in response to user interactions (button clicks, dropdown changes, etc.)
- ✅ API methods CAN be called inside GridEvents handlers
4. Use Async/Await Pattern
- ✅ Always use
await with async API methods
- ✅ Define event handlers as
async Task
- ✅ Mark code block methods as
async Task
- ❌ Do not use synchronous method calls for async operations
5. Grid Reference Required for API Calls
- ✅ Use
@ref="Grid" to get the Grid instance
- ✅ Use the reference to call API methods (e.g.,
await Grid.GroupColumnAsync())
- ❌ Do not attempt to call methods without a reference
6. Event Types Must Match GridEvents TValue
- ✅ Set
TValue="YourDataType" to match your data model
- ✅ All event handlers will be properly typed with this model
- ❌ Do not use generic or wrong type for TValue
Navigation Guide
Setup & Getting Started
📄 Read: references/getting-started.md
- NuGet install,
_Imports.razor, Program.cs, theme/script setup, basic grid
📄 Read: references/getting-started-app-types.md
- Server App, Web App (Auto/WASM), MAUI variants
Data
📄 Read: references/data-binding.md
- Local (List, ExpandoObject, DynamicObject, DataTable, ObservableCollection)
Connecting to Adaptors (Remote Data)
📄 Read: references/odatav4-adaptor.md
- OData V4 service setup, ODataConventionModelBuilder, [EnableQuery], automatic $filter/$orderby/$skip/$top, CRUD with PATCH/DELETE
📄 Read: references/web-api-adaptor.md
- Web API with { Items, Count } response, manual $filter/$orderby/$skip/$top QueryString parsing, CRUD with GET/POST/PUT/DELETE
- Security note: Do NOT bind
SfDataManager.Url to arbitrary user-supplied URLs. Use an operator-configured string variable (for example Url="@DataApiUrl" where DataApiUrl is read from ALLOWED_API_URL in configuration), an internal proxy/gateway, field/operator whitelists, and server-side validation/sanitization. See references/web-api-adaptor.md Security Considerations for examples.
📄 Read: references/url-adaptor.md
- Custom API with { result, count } response, DataManagerRequest POST body, DataOperations helpers, InsertUrl/UpdateUrl/RemoveUrl/CrudUrl/BatchUrl
- Security note: Use a configuration-backed URL variable (for example
Url="@DataApiUrl" where DataApiUrl is read from ALLOWED_API_URL in configuration), avoid user-supplied endpoints, and route third-party requests through an internal proxy/gateway. See references/url-adaptor.md for examples and configuration snippets.
📄 Read: references/custom-adaptor.md
- DataAdaptor abstract class, override Read/Insert/Update/Remove/BatchUpdate, service injection, adaptor as component, custom parameters via Query.AddParams
- Security note: When implementing
CustomAdaptor, do not trust dm.Params or user-supplied endpoints. Use operator-configured endpoints, validate dm.Params, whitelist fields/operators, and route third-party calls through a proxy. See references/custom-adaptor.md Security Considerations for examples.
Columns
📄 Read: references/columns.md
- ColumnType, Format, TextAlign, frozen, reorder, resize, chooser, stacked headers, column menu, foreign key
📄 Read: references/cell.md
- QueryCellInfo, CustomAttributes, ClipMode, GridLines, tooltips
Sorting, Filtering, Searching
📄 Read: references/sorting.md
- AllowSorting, multi-sort, SortColumnAsync, ClearSortingAsync
📄 Read: references/filtering.md
- AllowFiltering, FilterType (FilterBar/Menu/Excel/CheckBox), operators, FilterByColumnAsync
📄 Read: references/searching.md
- Toolbar Search, SearchAsync, GridSearchSettings
Grouping & Paging
📄 Read: references/grouping.md
- AllowGrouping, lazy load grouping, CaptionTemplate, programmatic group/ungroup
📄 Read: references/paging.md
- AllowPaging, GridPageSettings, pager template, GoToPageAsync
Scrolling
📄 Read: references/scrolling.md
- Height/Width, sticky header, ScrollIntoViewAsync
📄 Read: references/virtual-scrolling.md
- EnableVirtualization, EnableColumnVirtualization, OverscanCount, limitations
📄 Read: references/infinite-scrolling.md
- EnableInfiniteScrolling, GridInfiniteScrollSettings, cache mode, limitations
Editing
📄 Read: references/editing.md
- GridEditSettings, EditMode (Normal/Dialog/Batch/CommandColumn), ValidationRules, EditType, EditTemplate, CRUD methods
Read: references/editing-patterns.md
- Cancel edit based on condition, disable editing for specific rows
- Provide new/edited item via events, default column values, new row position
- Always-show add-new-row form, delete multiple rows, single-click editing
- Save new row at a specific index, inline template editing
📄 Read: references/editing-validation.md
- Per-column
ValidationRules, Data Annotation attributes ([Required], [Range], etc.)
- Custom validation attributes, complex type validation, custom validator component
Selection
📄 Read: references/selection.md
- AllowSelection, SelectionMode, SelectionType, checkbox selection, programmatic selection
📄 Read: references/clipboard.md
- Clipboard copy (Ctrl+C / Ctrl+Shift+H), CopyAsync, AutoFill drag handle, Paste (Ctrl+V), batch editing requirements
Aggregates
📄 Read: references/aggregates.md
- GridAggregates, AggregateType, FooterTemplate, GroupFooterTemplate, GroupCaptionTemplate, reactive aggregates
Row Features & Templates
📄 Read: references/row-features.md
- RowDataBound, row drag-drop, row height, row spanning, RowTemplate
📄Read: references/templates-structural.md
- ColumnTemplate (image, hyperlink, checkbox, SfChip), HeaderTemplate, RowTemplate, RowTemplate formatting, DetailTemplate, expand/collapse APIs, expand on load, hide expand icon, custom CSS icons, hierarchical nested Grid
📄 Read: references/templates-interactive.md
- ToolbarTemplate, Column EditTemplate, GridEditSettings Template, disable inputs on add vs edit, triple underscore nested binding, focus editor on dialog open, RowUpdating transform, FooterTemplate, CaptionTemplate, custom Blazor component in caption, locale customization, PagerTemplate
Toolbar, Context Menu
📄 Read: references/toolbar.md
- Built-in/custom toolbar items, OnToolbarClick, ToolbarTemplate
📄 Read: references/context-menu.md
- ContextMenuItems, custom items, ContextMenuItemClicked
Export & Print
📄 Read: references/excel-export.md
- AllowExcelExport, ExportToExcelAsync, ExcelExportProperties, theme/template export
📄 Read: references/pdf-export.md
- AllowPdfExport, ExportToPdfAsync, PdfExportProperties, template PDF export
📄 Read: references/print.md
Performance, Events, State
📄 Read: references/performance.md
- SetRowDataAsync, PreventRender, WebAssembly optimization, column virtualization tips
📄 Read: references/events.md
- Complete GridEvents reference: all edit, selection, filter, sort, group, page, toolbar, export events
📄 Read: references/state-management.md
- EnablePersistence, GetPersistDataAsync, SetPersistDataAsync, ResetPersistDataAsync
Styling & Adaptive UI
📄 Read: references/style-and-appearance.md
- CSS classes for grid, header, rows, filtering, editing, grouping, aggregates
📄 Read: references/adaptive-layout.md
- EnableAdaptiveUI, RowRenderingMode, AdaptiveUIMode, mobile-responsive patterns
Quick Start
@page "/datagrid-demo"
@using Syncfusion.Blazor.Grids
<SfGrid DataSource="@Orders" AllowPaging="true" AllowSorting="true" AllowFiltering="true">
<GridPageSettings PageSize="10"></GridPageSettings>
<GridColumns>
<GridColumn Field="OrderID" HeaderText="Order ID" IsPrimaryKey="true" Width="120" TextAlign="TextAlign.Right"></GridColumn>
<GridColumn Field="CustomerID" HeaderText="Customer" Width="150"></GridColumn>
<GridColumn Field="Freight" HeaderText="Freight" Format="C2" Width="120" TextAlign="TextAlign.Right"></GridColumn>
<GridColumn Field="OrderDate" HeaderText="Order Date" Format="d" Width="150" Type="ColumnType.Date"></GridColumn>
<GridColumn Field="ShipCountry" HeaderText="Ship Country" Width="150"></GridColumn>
</GridColumns>
</SfGrid>
@code {
public List<Order> Orders = new List<Order>
{
new Order { OrderID = 10248, CustomerID = "VINET", Freight = 32.38, OrderDate = new DateTime(1996,7,4), ShipCountry = "France" },
new Order { OrderID = 10249, CustomerID = "TOMSP", Freight = 11.61, OrderDate = new DateTime(1996,7,5), ShipCountry = "Germany" },
};
public class Order
{
public int OrderID { get; set; }
public string CustomerID { get; set; }
public double Freight { get; set; }
public DateTime OrderDate { get; set; }
public string ShipCountry { get; set; }
}
}
Common Patterns
Grid with Editing + Toolbar
<SfGrid DataSource="@Orders" Toolbar="@(new List<string>() { "Add","Edit","Delete","Update","Cancel" })">
<GridEditSettings AllowAdding="true" AllowEditing="true" AllowDeleting="true" Mode="EditMode.Normal"></GridEditSettings>
<GridColumns>
<GridColumn Field="OrderID" IsPrimaryKey="true" ValidationRules="@(new ValidationRules{Required=true})"></GridColumn>
<GridColumn Field="CustomerID" ValidationRules="@(new ValidationRules{Required=true})"></GridColumn>
<GridColumn Field="Freight" EditType="EditType.NumericEdit"></GridColumn>
</GridColumns>
</SfGrid>
Grid with Grouping + Paging
<SfGrid DataSource="@Orders" AllowGrouping="true" AllowPaging="true">
<GridGroupSettings Columns="@(new string[]{"ShipCountry"})"></GridGroupSettings>
<GridPageSettings PageSize="10"></GridPageSettings>
<GridColumns>
<GridColumn Field="OrderID" Width="120"></GridColumn>
<GridColumn Field="CustomerID" Width="150"></GridColumn>
<GridColumn Field="ShipCountry" Width="150"></GridColumn>
</GridColumns>
</SfGrid>
Grid Reference for Programmatic Control
<SfGrid @ref="Grid" DataSource="@Orders">...</SfGrid>
@code {
SfGrid<Order> Grid;
// Programmatic operations:
// await Grid.SortColumnAsync("OrderID", SortDirection.Ascending, false);
// await Grid.FilterByColumnAsync("ShipCountry", "equal", "France");
// await Grid.GoToPageAsync(2);
// await Grid.StartEditAsync();
// await Grid.SelectRowAsync(0);
}
Key Properties at a Glance
| Property |
Description |
DataSource |
Bind IEnumerable<T> or DataManagerRequest |
AllowPaging |
Enable paging |
AllowSorting |
Enable sorting |
AllowFiltering |
Enable column filtering |
AllowGrouping |
Enable row grouping |
AllowSelection |
Enable row/cell selection |
Height / Width |
Fixed dimensions for scrolling |
Toolbar |
Built-in or custom toolbar items |
EnableVirtualization |
Row virtualization for large data |
EnableInfiniteScrolling |
Infinite scroll loading |
EnablePersistence |
Save state to localStorage |
EnableAdaptiveUI |
Mobile-responsive rendering |
1---
2name: syncfusion-blazor-datagrid
3description: Implements the Syncfusion Blazor DataGrid (SfGrid) for efficient tabular operations such as sorting, filtering, paging, grouping, editing, aggregates, virtualization, lazy‑load grouping, and row or column spanning. Use this skill when building data‑grid workflows in Blazor Server, WebAssembly, Web App, or MAUI applications. Supports Excel/PDF export, virtual or infinite scrolling, customizable templates, and grid state persistence for consistent and optimized data‑grid behavior.
4metadata:
5 author: "Syncfusion Inc"
6 version: "34.1.29"
7---
8
9***
10
11# Implementing Syncfusion Blazor DataGrid
12
13The Syncfusion Blazor DataGrid (`SfGrid<TValue>`) is a high-performance, feature-rich component for displaying and manipulating tabular data. It supports data binding, sorting, filtering, grouping, paging, editing, selection, aggregates, export, virtual/infinite scrolling, templates, and more.
14
15**NuGet:** `Syncfusion.Blazor.Grid` + `Syncfusion.Blazor.Themes`
16**Namespace:** `Syncfusion.Blazor.Grids`
17
18## When to Use This Skill
19
20Use this skill when you need to:
21- Set up and configure a DataGrid in Blazor Server, WebAssembly, Web App, or MAUI
22- Bind local or remote data (OData, HTTP, SfDataManager)
23- Configure columns (type, format, template, frozen, reorder, resize, chooser)
24- Implement sorting, filtering (FilterBar/Menu/Excel/CheckBox), or searching
25- Enable grouping with lazy load or caption templates
26- Configure paging with custom templates or SfPager
27- Set up virtual scrolling, infinite scrolling for large datasets
28- Implement editing (Normal/Dialog/Batch/Command column) with validation
29- Configure selection (row, cell, checkbox) with programmatic control
30- Use clipboard copy, AutoFill, or Paste features
31- Add aggregates (footer, group, caption, reactive)
32- Use row/column templates, detail template, row drag-drop
33- Configure toolbar, context menu, column menu, column chooser
34- Export data to Excel or PDF
35- Manage print functionality
36- Optimize performance (SetRowDataAsync, PreventRender)
37- Handle DataGrid events
38- Manage state persistence (EnablePersistence)
39- Customize styling and appearance
40- Enable adaptive UI for mobile/responsive layouts
41
42# 🔒 Mandatory Key Rules
43
44These rules govern how this skill MUST behave. They are mandatory and must be strictly followed.
45
46## 1. Purpose and Responsibility
47
48Your responsibility is to interpret any natural‑language user request and provide:
49
50* Accurate
51* Complete
52* Validated
53
54information about all supported aspects of the **Syncfusion Blazor DataGrid**, including:
55
56* Public APIs
57* Properties
58* Events
59* Features
60* Behaviors
61
62## 2. Accuracy and API Compliance
63
64The Skill MUST:
65
66* Use **only officially supported** Syncfusion DataGrid features.
67* **NEVER** invent APIs, methods, properties, events, behaviors, or future features.
68* **NEVER** provide unsupported or hypothetical code samples.
69* ALWAYS follow official Syncfusion component design patterns.
70
71If a feature is **not supported**:
72
73* Clearly state the limitation.
74* Suggest a supported alternative when possible.
75
76## 3. Interpreting Natural-Language Requests
77
78When user requests are incomplete:
79
80* Infer reasonable assumptions using official Grid best practices.
81* Fill missing gaps with accurate and relevant information.
82* Request clarification **only** when essential.
83
84## 4. Response Quality Requirements
85
86Every response MUST:
87
88* Be technically accurate
89* Be complete and well‑structured
90* Include required dependencies and configuration notes
91* Follow real, documented Syncfusion API behavior
92* Avoid contradictions or ambiguity
93
94## 5. Handling Unsupported User Requests
95
96If the user asks for an unsupported capability:
97
98* Explicitly state that it is not supported
99* Suggest official alternatives or valid workarounds
100* NEVER simulate or fabricate impossible functionality
101
102## 6. Design Pattern Enforcement
103
104The Skill MUST follow Syncfusion official patterns, including:
105
106* Correct component structure (`SfGrid`, `GridColumn`, `GridEditSettings`, etc.)
107* Proper async event and API usage
108* Valid configuration properties and enums
109* Supported data‑binding approaches
110* Real event patterns and names
111
112## 7. Quality, Completeness & Reliability
113
114The Skill MUST:
115
116* Use only validated and real Grid capabilities
117* Provide actionable and implementation‑ready guidance
118* Ensure clarity so users can follow without guesswork
119* Maintain clean, readable, and professional formatting
120
121## 8. No-Hallucination Safeguard
122
123The Skill MUST NOT:
124
125* Invent non‑existent APIs or behavior
126* Suggest unsupported modes, features, or configuration
127* Provide incorrect, misleading, or unverifiable code
128* Describe undocumented internal behavior
129
130If unsure:
131
132* Ask for clarification **OR**
133* Clearly state the limitation
134
135## 9. Event Name Verification Requirement
136
137**CRITICAL:** Event names MUST be verified against `references/events.md` BEFORE providing code examples. All grid events MUST be defined inside the `<GridEvents>` component
138
139**Common Mistakes to Avoid:**
140
141* ❌ `OnSortChange` - Does NOT exist. Use `Sorting`, `Sorted` instead
142* ❌ `OnFilterChange` - Does NOT exist. Use `Filtering`, `Filtered` instead
143* ❌ `OnPageChange` - Does NOT exist. Use `PageChanging`, `PageChanged` instead
144* ❌ `OnGroupChange` - Does NOT exist. Use `Grouping`, `Grouped` instead
145
146**Rule:** ALWAYS cross-reference `references/events.md` for:
147
148* Exact event names (case-sensitive)
149* Event argument types
150* Whether events are cancelable
151* When they fire (before/after operation)
152
153**Verification Checklist Before Providing Event Code:**
154
1551. Check if event name exists in `references/events.md`
1562. Verify the correct `EventArgs` type
1573. Confirm `Cancelable` status (✅ or ❌)
1584. Test against actual Syncfusion documentation
1595. Never assume naming conventions (e.g., `On` prefix, `Change` suffix)
160
161---
162
163## Strict Rules for Grid Events
164
165### 1. **Event Handlers MUST be in `<GridEvents>` Component**
166 - ✅ Define ALL event handlers inside `<GridEvents TValue="YourType">`
167 - ✅ Use the exact event names as properties (e.g., `DataBound`, `RowSelecting`, `Grouped`)
168 - ❌ DO NOT use `@onEventName` syntax on `<SfGrid>`
169 - ❌ DO NOT define event handlers on any root element
170
171### 2. **Correct Event Handler Signatures**
172 - ✅ Use `async Task` for event handlers
173 - ✅ Event handlers may have specific parameter types (e.g., `GridEventArgs`, `RowSelectEventArgs`)
174 - ✅ Some events have no parameters (e.g., `DataBound()`, `Created()`)
175 - ❌ Do not use synchronous `void` methods for async operations
176
177### 3. **API Method Calls MUST NOT be in Lifecycle Events**
178 - ❌ DO NOT call API methods in `OnInitialized()`
179 - ❌ DO NOT call API methods in `OnAfterRenderAsync()`
180 - ❌ DO NOT call API methods in `OnParametersSet()`
181 - ✅ ONLY call API methods in response to user interactions (button clicks, dropdown changes, etc.)
182 - ✅ API methods CAN be called inside GridEvents handlers
183
184### 4. **Use Async/Await Pattern**
185 - ✅ Always use `await` with async API methods
186 - ✅ Define event handlers as `async Task`
187 - ✅ Mark code block methods as `async Task`
188 - ❌ Do not use synchronous method calls for async operations
189
190### 5. **Grid Reference Required for API Calls**
191 - ✅ Use `@ref="Grid"` to get the Grid instance
192 - ✅ Use the reference to call API methods (e.g., `await Grid.GroupColumnAsync()`)
193 - ❌ Do not attempt to call methods without a reference
194
195### 6. **Event Types Must Match GridEvents TValue**
196 - ✅ Set `TValue="YourDataType"` to match your data model
197 - ✅ All event handlers will be properly typed with this model
198 - ❌ Do not use generic or wrong type for TValue
199
200---
201
202## Navigation Guide
203
204### Setup & Getting Started
205📄 **Read:** [references/getting-started.md](references/getting-started.md)
206- NuGet install, `_Imports.razor`, `Program.cs`, theme/script setup, basic grid
207
208📄 **Read:** [references/getting-started-app-types.md](references/getting-started-app-types.md)
209- Server App, Web App (Auto/WASM), MAUI variants
210
211### Data
212📄 **Read:** [references/data-binding.md](references/data-binding.md)
213- Local (List, ExpandoObject, DynamicObject, DataTable, ObservableCollection)
214
215### Connecting to Adaptors (Remote Data)
216📄 **Read:** [references/odatav4-adaptor.md](references/odatav4-adaptor.md)
217- OData V4 service setup, ODataConventionModelBuilder, [EnableQuery], automatic $filter/$orderby/$skip/$top, CRUD with PATCH/DELETE
218
219📄 **Read:** [references/web-api-adaptor.md](references/web-api-adaptor.md)
220- Web API with { Items, Count } response, manual $filter/$orderby/$skip/$top QueryString parsing, CRUD with GET/POST/PUT/DELETE
221- **Security note:** Do NOT bind `SfDataManager.Url` to arbitrary user-supplied URLs. Use an operator-configured string variable (for example `Url="@DataApiUrl"` where `DataApiUrl` is read from `ALLOWED_API_URL` in configuration), an internal proxy/gateway, field/operator whitelists, and server-side validation/sanitization. See [references/web-api-adaptor.md](references/web-api-adaptor.md) `Security Considerations` for examples.
222
223📄 **Read:** [references/url-adaptor.md](references/url-adaptor.md)
224- Custom API with { result, count } response, DataManagerRequest POST body, DataOperations helpers, InsertUrl/UpdateUrl/RemoveUrl/CrudUrl/BatchUrl
225- **Security note:** Use a configuration-backed URL variable (for example `Url="@DataApiUrl"` where `DataApiUrl` is read from `ALLOWED_API_URL` in configuration), avoid user-supplied endpoints, and route third-party requests through an internal proxy/gateway. See [references/url-adaptor.md](references/url-adaptor.md) for examples and configuration snippets.
226
227📄 **Read:** [references/custom-adaptor.md](references/custom-adaptor.md)
228- DataAdaptor abstract class, override Read/Insert/Update/Remove/BatchUpdate, service injection, adaptor as component, custom parameters via Query.AddParams
229- **Security note:** When implementing `CustomAdaptor`, do not trust `dm.Params` or user-supplied endpoints. Use operator-configured endpoints, validate `dm.Params`, whitelist fields/operators, and route third-party calls through a proxy. See [references/custom-adaptor.md](references/custom-adaptor.md) `Security Considerations` for examples.
230
231### Columns
232📄 **Read:** [references/columns.md](references/columns.md)
233- ColumnType, Format, TextAlign, frozen, reorder, resize, chooser, stacked headers, column menu, foreign key
234
235📄 **Read:** [references/cell.md](references/cell.md)
236- QueryCellInfo, CustomAttributes, ClipMode, GridLines, tooltips
237
238### Sorting, Filtering, Searching
239📄 **Read:** [references/sorting.md](references/sorting.md)
240- AllowSorting, multi-sort, SortColumnAsync, ClearSortingAsync
241
242📄 **Read:** [references/filtering.md](references/filtering.md)
243- AllowFiltering, FilterType (FilterBar/Menu/Excel/CheckBox), operators, FilterByColumnAsync
244
245📄 **Read:** [references/searching.md](references/searching.md)
246- Toolbar Search, SearchAsync, GridSearchSettings
247
248### Grouping & Paging
249📄 **Read:** [references/grouping.md](references/grouping.md)
250- AllowGrouping, lazy load grouping, CaptionTemplate, programmatic group/ungroup
251
252📄 **Read:** [references/paging.md](references/paging.md)
253- AllowPaging, GridPageSettings, pager template, GoToPageAsync
254
255### Scrolling
256📄 **Read:** [references/scrolling.md](references/scrolling.md)
257- Height/Width, sticky header, ScrollIntoViewAsync
258
259📄 **Read:** [references/virtual-scrolling.md](references/virtual-scrolling.md)
260- EnableVirtualization, EnableColumnVirtualization, OverscanCount, limitations
261
262📄 **Read:** [references/infinite-scrolling.md](references/infinite-scrolling.md)
263- EnableInfiniteScrolling, GridInfiniteScrollSettings, cache mode, limitations
264
265### Editing
266📄 **Read:** [references/editing.md](references/editing.md)
267- GridEditSettings, EditMode (Normal/Dialog/Batch/CommandColumn), ValidationRules, EditType, EditTemplate, CRUD methods
268
269 **Read:** [references/editing-patterns.md](references/editing-patterns.md)
270- Cancel edit based on condition, disable editing for specific rows
271- Provide new/edited item via events, default column values, new row position
272- Always-show add-new-row form, delete multiple rows, single-click editing
273- Save new row at a specific index, inline template editing
274
275📄 **Read:** [references/editing-validation.md](references/editing-validation.md)
276- Per-column `ValidationRules`, Data Annotation attributes (`[Required]`, `[Range]`, etc.)
277- Custom validation attributes, complex type validation, custom validator component
278
279
280### Selection
281📄 **Read:** [references/selection.md](references/selection.md)
282- AllowSelection, SelectionMode, SelectionType, checkbox selection, programmatic selection
283
284📄 **Read:** [references/clipboard.md](references/clipboard.md)
285- Clipboard copy (Ctrl+C / Ctrl+Shift+H), CopyAsync, AutoFill drag handle, Paste (Ctrl+V), batch editing requirements
286
287### Aggregates
288📄 **Read:** [references/aggregates.md](references/aggregates.md)
289- GridAggregates, AggregateType, FooterTemplate, GroupFooterTemplate, GroupCaptionTemplate, reactive aggregates
290
291### Row Features & Templates
292📄 **Read:** [references/row-features.md](references/row-features.md)
293- RowDataBound, row drag-drop, row height, row spanning, RowTemplate
294
295📄**Read:** [references/templates-structural.md](references/templates-structural.md)
296- ColumnTemplate (image, hyperlink, checkbox, SfChip), HeaderTemplate, RowTemplate, RowTemplate formatting, DetailTemplate, expand/collapse APIs, expand on load, hide expand icon, custom CSS icons, hierarchical nested Grid
297
298📄 **Read:** [references/templates-interactive.md](references/templates-interactive.md)
299- ToolbarTemplate, Column EditTemplate, GridEditSettings Template, disable inputs on add vs edit, triple underscore nested binding, focus editor on dialog open, RowUpdating transform, FooterTemplate, CaptionTemplate, custom Blazor component in caption, locale customization, PagerTemplate
300
301### Toolbar, Context Menu
302📄 **Read:** [references/toolbar.md](references/toolbar.md)
303- Built-in/custom toolbar items, OnToolbarClick, ToolbarTemplate
304
305📄 **Read:** [references/context-menu.md](references/context-menu.md)
306- ContextMenuItems, custom items, ContextMenuItemClicked
307
308### Export & Print
309📄 **Read:** [references/excel-export.md](references/excel-export.md)
310- AllowExcelExport, ExportToExcelAsync, ExcelExportProperties, theme/template export
311
312📄 **Read:** [references/pdf-export.md](references/pdf-export.md)
313- AllowPdfExport, ExportToPdfAsync, PdfExportProperties, template PDF export
314
315📄 **Read:** [references/print.md](references/print.md)
316- PrintAsync, PrintMode
317
318### Performance, Events, State
319📄 **Read:** [references/performance.md](references/performance.md)
320- SetRowDataAsync, PreventRender, WebAssembly optimization, column virtualization tips
321
322📄 **Read:** [references/events.md](references/events.md)
323- Complete GridEvents<TValue> reference: all edit, selection, filter, sort, group, page, toolbar, export events
324
325📄 **Read:** [references/state-management.md](references/state-management.md)
326- EnablePersistence, GetPersistDataAsync, SetPersistDataAsync, ResetPersistDataAsync
327
328### Styling & Adaptive UI
329📄 **Read:** [references/style-and-appearance.md](references/style-and-appearance.md)
330- CSS classes for grid, header, rows, filtering, editing, grouping, aggregates
331
332📄 **Read:** [references/adaptive-layout.md](references/adaptive-layout.md)
333- EnableAdaptiveUI, RowRenderingMode, AdaptiveUIMode, mobile-responsive patterns
334
335## Quick Start
336
337```razor
338@page "/datagrid-demo"
339@using Syncfusion.Blazor.Grids
340
341<SfGrid DataSource="@Orders" AllowPaging="true" AllowSorting="true" AllowFiltering="true">
342 <GridPageSettings PageSize="10"></GridPageSettings>
343 <GridColumns>
344 <GridColumn Field="OrderID" HeaderText="Order ID" IsPrimaryKey="true" Width="120" TextAlign="TextAlign.Right"></GridColumn>
345 <GridColumn Field="CustomerID" HeaderText="Customer" Width="150"></GridColumn>
346 <GridColumn Field="Freight" HeaderText="Freight" Format="C2" Width="120" TextAlign="TextAlign.Right"></GridColumn>
347 <GridColumn Field="OrderDate" HeaderText="Order Date" Format="d" Width="150" Type="ColumnType.Date"></GridColumn>
348 <GridColumn Field="ShipCountry" HeaderText="Ship Country" Width="150"></GridColumn>
349 </GridColumns>
350</SfGrid>
351
352@code {
353 public List<Order> Orders = new List<Order>
354 {
355 new Order { OrderID = 10248, CustomerID = "VINET", Freight = 32.38, OrderDate = new DateTime(1996,7,4), ShipCountry = "France" },
356 new Order { OrderID = 10249, CustomerID = "TOMSP", Freight = 11.61, OrderDate = new DateTime(1996,7,5), ShipCountry = "Germany" },
357 };
358 public class Order
359 {
360 public int OrderID { get; set; }
361 public string CustomerID { get; set; }
362 public double Freight { get; set; }
363 public DateTime OrderDate { get; set; }
364 public string ShipCountry { get; set; }
365 }
366}
367```
368
369## Common Patterns
370
371### Grid with Editing + Toolbar
372```razor
373<SfGrid DataSource="@Orders" Toolbar="@(new List<string>() { "Add","Edit","Delete","Update","Cancel" })">
374 <GridEditSettings AllowAdding="true" AllowEditing="true" AllowDeleting="true" Mode="EditMode.Normal"></GridEditSettings>
375 <GridColumns>
376 <GridColumn Field="OrderID" IsPrimaryKey="true" ValidationRules="@(new ValidationRules{Required=true})"></GridColumn>
377 <GridColumn Field="CustomerID" ValidationRules="@(new ValidationRules{Required=true})"></GridColumn>
378 <GridColumn Field="Freight" EditType="EditType.NumericEdit"></GridColumn>
379 </GridColumns>
380</SfGrid>
381```
382
383### Grid with Grouping + Paging
384```razor
385<SfGrid DataSource="@Orders" AllowGrouping="true" AllowPaging="true">
386 <GridGroupSettings Columns="@(new string[]{"ShipCountry"})"></GridGroupSettings>
387 <GridPageSettings PageSize="10"></GridPageSettings>
388 <GridColumns>
389 <GridColumn Field="OrderID" Width="120"></GridColumn>
390 <GridColumn Field="CustomerID" Width="150"></GridColumn>
391 <GridColumn Field="ShipCountry" Width="150"></GridColumn>
392 </GridColumns>
393</SfGrid>
394```
395
396### Grid Reference for Programmatic Control
397```razor
398<SfGrid @ref="Grid" DataSource="@Orders">...</SfGrid>
399@code {
400 SfGrid<Order> Grid;
401 // Programmatic operations:
402 // await Grid.SortColumnAsync("OrderID", SortDirection.Ascending, false);
403 // await Grid.FilterByColumnAsync("ShipCountry", "equal", "France");
404 // await Grid.GoToPageAsync(2);
405 // await Grid.StartEditAsync();
406 // await Grid.SelectRowAsync(0);
407}
408```
409
410## Key Properties at a Glance
411
412| Property | Description |
413|---|---|
414| `DataSource` | Bind `IEnumerable<T>` or `DataManagerRequest` |
415| `AllowPaging` | Enable paging |
416| `AllowSorting` | Enable sorting |
417| `AllowFiltering` | Enable column filtering |
418| `AllowGrouping` | Enable row grouping |
419| `AllowSelection` | Enable row/cell selection |
420| `Height` / `Width` | Fixed dimensions for scrolling |
421| `Toolbar` | Built-in or custom toolbar items |
422| `EnableVirtualization` | Row virtualization for large data |
423| `EnableInfiniteScrolling` | Infinite scroll loading |
424| `EnablePersistence` | Save state to localStorage |
425| `EnableAdaptiveUI` | Mobile-responsive rendering |
426````