@page "/"
@using Syncfusion.EJ2.Blazor.Grids
@using Syncfusion.EJ2.Blazor.Data
<h1>Hello, world!</h1>
<EjsGrid @ref="@grid" AllowPaging="true" AllowSorting="true" AllowGrouping="true" AllowFiltering="true" Toolbar="@(new List<string> { "Add", "Edit", "Delete", "Update", "Cancel"})">
<GridPageSettings PageSize="4"></GridPageSettings>
<EjsDataManager Url="/api/Default" Adaptor="Adaptors.WebApiAdaptor"></EjsDataManager>
<GridEditSettings AllowAdding="true" AllowEditing="true" AllowDeleting="true"></GridEditSettings>
<GridColumns>
<GridColumn Field="OrderID" HeaderText="Order ID" IsPrimaryKey="true" IsIdentity="true" TextAlign="@TextAlign.Right" Width="90"></GridColumn>
<GridColumn Field="CustomerID" HeaderText="Customer Name" Width="90"></GridColumn>
<GridColumn Field="EmployeeID" HeaderText="First Name" ForeignKeyField="EmployeeID" ForeignKeyValue="FirstName" DataSource="@(new Syncfusion
.EJ2.Blazor.DataManager(){ Url = "api/Employee", Adaptor= Syncfusion.EJ2.Blazor.Adaptors.WebApiAdaptor})" Width="90"></GridColumn>
</GridColumns>
</EjsGrid>
@functions{
EjsGrid grid;
} |
Hi Ebi,Query: “when we want Add entity in this grid,if "IsIdentity" Is "true" , After clicking on the "Update" button, the "Post" method runs else if "IsIdentity" Is "false" "Update" button does not submited.”In the provided sample, OrderID column is the IsPrimaryKey column. So while adding its value must be sent to server for proper functioning of CRUD operation. When PrimaryKey column is IsIdentity column, then post will be sent to server and value for PrimaryKey column will be auto generated from our source.
If you disable the IsIdentity column, then you need to pass the value for OrderID (primaryKey column) while sending POST request. We suspect that value for primaryKey is not sent to server properly, hence reported issue is occurred. So kindly give the value for primaryKey column while adding.
Still you are facing the issue share the video demonstration of reported issue with replication procedure.
Regards,Vignesh Natarajan.
<EjsGrid @ref="@grid" ...>
<GridPageSettings PageSize="4"></GridPageSettings>
<EjsDataManager Url="/api/Default" Adaptor="Adaptors.WebApiAdaptor"></EjsDataManager>
<GridEditSettings AllowAdding="true" AllowEditing="true" AllowDeleting="true"></GridEditSettings>
<GridColumns>
<GridColumn Field="OrderID" HeaderText="Order ID" IsPrimaryKey="true" IsIdentity="true" TextAlign="@TextAlign.Right" Width="90"></GridColumn>
...
</GridColumns>
</EjsGrid>
public static List<Orders> order = new List<Orders>();
...
[HttpPost]
public void Post([FromBody]Orders Order)
{
// increment the primaryKey value at server side
Order.OrderID = order[order.Count - 1].OrderID + 1;
Orders.GetAllRecords().Insert(0, Order);
}
public class Orders
{
...
//Set the nullable type for “OrderID” column – isIdentity Column
public long? OrderID { get; set; }
public string CustomerID { get; set; }
...
}
|