|
<SfGrid @ref="Grid" TValue="Orders" AllowFiltering="true" AllowSorting="true" AllowPaging="true"
Toolbar="@(new List<string>() { "Add", "Edit", "Delete", "Cancel", "Update" })">
<GridEditSettings AllowAdding="true" AllowEditing="true" AllowDeleting="true" Mode="EditMode.Normal"></GridEditSettings>
<SfDataManager Url="api/Default" Adaptor="Adaptors.WebApiAdaptor"></SfDataManager>
<GridColumns>
<GridColumn Field="OrderID" HeaderText="Order ID" IsPrimaryKey="true" TextAlign="TextAlign.Right" Width="120"></GridColumn>
<GridColumn Field="CustomerID" HeaderText="Customer Name" Width="150"></GridColumn>
<GridColumn Field="Freight" HeaderText="Freight" Format="C2" TextAlign="TextAlign.Right" Width="120"></GridColumn>
</GridColumns>
</SfGrid>
|
Hi Matt,
Greetings from Syncfusion.
Query: But if I have datasource the grid shows records but then i add / edit / delete records doesnt work.
We have validated your query with the provided information and you have used both DataSource property and SfDataManager to bind the data to the Grid. You should use either one of the way(using DataSource or SfDataManager) to bind the data to the Grid.
Also, we have prepared a sample based on your requirement. The CRUD operations are working fine without any issues. Find the below code snippets and sample for your reference.
<SfGrid @ref="Grid" TValue="Orders" AllowFiltering="true" AllowSorting="true" AllowPaging="true"Toolbar="@(new List<string>() { "Add", "Edit", "Delete", "Cancel", "Update" })"><GridEditSettings AllowAdding="true" AllowEditing="true" AllowDeleting="true" Mode="EditMode.Normal"></GridEditSettings><SfDataManager Url="api/Default" Adaptor="Adaptors.WebApiAdaptor"></SfDataManager><GridColumns><GridColumn Field="OrderID" HeaderText="Order ID" IsPrimaryKey="true" TextAlign="TextAlign.Right" Width="120"></GridColumn><GridColumn Field="CustomerID" HeaderText="Customer Name" Width="150"></GridColumn><GridColumn Field="Freight" HeaderText="Freight" Format="C2" TextAlign="TextAlign.Right" Width="120"></GridColumn></GridColumns></SfGrid>
Reference:
Please let us know if you have any concerns.
Regards,Rahul