Hi Paul,
Greetings from Syncfusion.
We have validated your queries with the provided information. From your shared information, you want use multiple primary keys in Grid. Currently we don’t have support for multiple primary key column in Grid. But we have considered this requirement as a feature and logged a feature task “Provide multiple primary key column support in Grid” for this and added to our feature request list. Based on specific parameters including product vision and technological feasibility we will implement this feature. This will be available in any of our upcoming releases.
You can now track the current status of your request, review the proposed resolution timeline, and contact us for any further inquiries through this link.
Query: Is there a way to get all primary keys in my Custom Adaptor?
Yes, you can get the primary key field names by using GetPrimaryKeyFieldNames method of the Grid. find the below API link for your reference.
Query: Why can the grid not have a built in Entity Framework Adaptor for server side projects that does all of this work automatically?
From your query, you want an adaptor for consuming date from Entity framework and perform other Grid operations(paging, sorting, filtering, etc). For this we suggest you to use the CustomAdaptor concept to achieve your requirement.
Reference:
Query: then is there a generic Adaptor that I can use instead of making one for each table I use in my edit grids?
You want to use same CustomAdaptor(Generic Adaptor) for multiple tables. Yes, you can achieve your requirement by using CustomAdaptor as a Component. Here, we can define the CustomAdaptor component as Generic one and use that component inside various Grid / components. Refer the below code example.
|
[Index.razor]
<SfGrid TValue="Order" AllowPaging="true" EnableHover="false" AllowSorting="true">
<GridPageSettings PageSize="5"></GridPageSettings>
<SfDataManager Adaptor="Adaptors.CustomAdaptor">
<CustomComponent T="Order" Details="Orders"></CustomComponent>
</SfDataManager>
<GridColumns>
….
</GridColumns>
</SfGrid>
[Test1.Razor]
<SfGrid TValue="Employee" AllowPaging="true" EnableHover="false" AllowSorting="true"> <GridPageSettings PageSize="5"></GridPageSettings> <SfDataManager Adaptor="Adaptors.CustomAdaptor"> <CustomComponent T="Employee" Details="Employees"></CustomComponent> </SfDataManager> <GridColumns>. . . . .. </GridColumns></SfGrid> |
[AdaptorComponent.Razor]
|
@typeparam T @inherits DataAdaptor<T> <CascadingValue Value="@this"> @ChildContent</CascadingValue> @code { [Parameter] [JsonIgnore] public RenderFragment ChildContent { get; set; } [Parameter] public List<T> Details { get; set; } // Performs data Read operation public override object Read(DataManagerRequest dm, string key = null) { IEnumerable<T> DataSource = (IEnumerable<T>)Details.Skip(dm.Skip).Take(dm.Take);. . . . . . . . . return dm.RequiresCounts ? new DataResult() { Result = DataSource, Count = count } : (object)DataSource; }}
|
In above example, we have used two different grid with same custom adaptor component. Similar way you can define the Generic CustomAdaptor component.
Kindly download the sample from below .
Reference:
Please get back to us if you need further assistance.
Regards,
Rahul