Loading...
Loading...
Implements Syncfusion Blazor SfDataManager for data access, data binding, and adaptor configuration in Blazor Server, WebAssembly, and Web App. Used when binding components like SfGrid and SfDropDownList to local or remote data sources, choosing adaptors (UrlAdaptor, ODataAdaptor, WebApiAdaptor, GraphQLAdaptor), or performing CRUD. Includes custom binding using DataAdaptor, DataManagerRequest, DataOperations, and the Syncfusion.Blazor.Data package.
npx skill4agent add syncfusion/blazor-ui-components-skills syncfusion-blazor-datamanagerSfGridSfDropDownListSfDataManagerJsonUrlAdaptorDataAdaptorHashSet<string>OnInitialized()*| Property | Purpose |
|---|---|
| Bind in-memory collection (local data) |
| Remote service endpoint |
| Specifies how requests/responses are processed |
| Type reference for |
| Custom HTTP headers for all outbound requests |
| Enable client-side processing after initial remote fetch |
| Query/mutation configuration for GraphQL services |
Syncfusion.Blazor.DataSyncfusion.Blazor.ThemesProgram.csSfGridSfDropDownListJsonUrlAdaptorSfGridSfDropDownListUrlAdaptorODataAdaptorODataV4AdaptorWebApiAdaptorresultcountGraphQLAdaptorOptionsQueryResolverNameInsertUpdateDeleteBatchDataManagerRequestProgram.csDataAdaptorReadReadAsyncDataOperationsInsertUpdateRemoveBatchUpdateCustomAdaptorSfGrid@using Syncfusion.Blazor.Data
@using Syncfusion.Blazor.Grids
<SfGrid TValue="EmployeeData" ID="Grid">
<SfDataManager Json="@Employees"></SfDataManager>
<GridColumns>
<GridColumn Field="@nameof(EmployeeData.EmployeeID)" HeaderText="Employee ID" Width="120"></GridColumn>
<GridColumn Field="@nameof(EmployeeData.Name)" HeaderText="First Name" Width="130"></GridColumn>
<GridColumn Field="@nameof(EmployeeData.Title)" HeaderText="Title" Width="120"></GridColumn>
</GridColumns>
</SfGrid>
@code {
public class EmployeeData
{
public int EmployeeID { get; set; }
public string Name { get; set; }
public string Title { get; set; }
}
public List<EmployeeData> Employees = new()
{
new EmployeeData { EmployeeID = 1, Name = "Nancy Fuller", Title = "Vice President" },
new EmployeeData { EmployeeID = 2, Name = "Steven Buchanan", Title = "Sales Manager" }
};
}@using Syncfusion.Blazor
@using Syncfusion.Blazor.Data
@using Syncfusion.Blazor.Grids
<!-- SECURITY: Use string variables for endpoints, validate against whitelist, use HTTPS only -->
<SfGrid TValue="Order" AllowPaging="true">
<SfDataManager Url="@ODataEndpointUrl"
Adaptor="Adaptors.ODataAdaptor">
</SfDataManager>
<GridColumns>
<GridColumn Field="@nameof(Order.OrderID)" HeaderText="Order ID" Width="120"></GridColumn>
<GridColumn Field="@nameof(Order.CustomerID)" HeaderText="Customer Name" Width="150"></GridColumn>
</GridColumns>
</SfGrid>
@code {
// Whitelist of trusted OData endpoints — define in appsettings.json in production
private static readonly HashSet<string> TrustedEndpoints = new()
{
"https://api.yourtrusted-domain.com/odata/"
};
// Assigned string variable for endpoint
private string ODataEndpointUrl { get; set; } = string.Empty;
protected override void OnInitialized()
{
// Validate and assign endpoint from configuration
const string endpointBase = "https://api.yourtrusted-domain.com/odata/Orders";
if (!TrustedEndpoints.Any(trusted => endpointBase.StartsWith(trusted)))
throw new InvalidOperationException($"Security validation failed: untrusted endpoint '{endpointBase}'");
ODataEndpointUrl = endpointBase;
}
public class Order
{
public int? OrderID { get; set; }
public string? CustomerID { get; set; }
}
}| Backend Type | Adaptor to Use |
|---|---|
Custom REST API returning | |
| OData v3 service | |
| OData v4 service | |
| ASP.NET Web API with OData query support | |
| GraphQL service | |
| Non-standard source / full custom control | |
SfDataManager<SfGrid TValue="MyModel">
<SfDataManager Url="..." Adaptor="Adaptors.WebApiAdaptor"></SfDataManager>
<GridColumns>...</GridColumns>
</SfGrid>CustomAdaptor<SfGrid TValue="Order" Toolbar="@(new List<string>() { "Add", "Delete", "Update", "Cancel" })">
<SfDataManager AdaptorInstance="@typeof(CustomAdaptor)" Adaptor="Adaptors.CustomAdaptor"></SfDataManager>
<GridEditSettings AllowEditing="true" AllowDeleting="true" AllowAdding="true" Mode="@EditMode.Normal"></GridEditSettings>
...
</SfGrid>