Loading...
Loading...
Compare original and translation side by side
SfGridSfDropDownListSfGridSfDropDownListSfDataManagerJsonUrlAdaptorDataAdaptorSfDataManagerJsonUrlAdaptorDataAdaptorHashSet<string>OnInitialized()*HashSet<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 |
| 属性 | 用途 |
|---|---|
| 绑定内存集合(本地数据) |
| 远程服务端点 |
| 指定请求/响应的处理方式 |
| |
| 所有出站请求的自定义HTTP头 |
| 初始远程获取后启用客户端处理 |
| GraphQL服务的查询/变更配置 |
Syncfusion.Blazor.DataSyncfusion.Blazor.ThemesProgram.csSfGridSfDropDownListSyncfusion.Blazor.DataSyncfusion.Blazor.ThemesProgram.csSfGridSfDropDownListJsonUrlAdaptorSfGridSfDropDownListJsonUrlAdaptorSfGridSfDropDownListUrlAdaptorODataAdaptorODataV4AdaptorWebApiAdaptorresultcountUrlAdaptorODataAdaptorODataV4AdaptorWebApiAdaptorresultcountGraphQLAdaptorOptionsQueryResolverNameInsertUpdateDeleteBatchDataManagerRequestProgram.csGraphQLAdaptorOptionsQueryResolverNameInsertUpdateDeleteBatchDataManagerRequestProgram.csDataAdaptorReadReadAsyncDataOperationsInsertUpdateRemoveBatchUpdateCustomAdaptorSfGridDataAdaptorDataOperationsReadReadAsyncInsertUpdateRemoveBatchUpdateSfGridCustomAdaptor@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.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; }
}
}@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 | |
| 后端类型 | 适用适配器 |
|---|---|
返回 | |
| OData v3服务 | |
| OData v4服务 | |
| 支持OData查询的ASP.NET Web API | |
| GraphQL服务 | |
| 非标准源 / 完全自定义控制 | |
SfDataManager<SfGrid TValue="MyModel">
<SfDataManager Url="..." Adaptor="Adaptors.WebApiAdaptor"></SfDataManager>
<GridColumns>...</GridColumns>
</SfGrid>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>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>