Hi,
I am using a dataGrid component in a ASP.NET Core Razor project to interact with a SQL database but cannot get the CRUD operations to work.
The routine defined in the removeURL property does not seem to be called at all.
Can you please tell me what is wrong with the code below? Thank you.
Index.cshtml
@page
...
@Html.AntiForgeryToken()
<ejs-grid id="GridPaikat"
allowpaging="true"
load="onLoad"
toolbar="@(new List<string>() {"Add", "Edit", "Update", "Delete", "Search", "Cancel" })">
<e-data-manager json="@Model.Havaintopaikka.ToArray()"
removeUrl="Remove"
adaptor="RemoteSaveAdaptor">
</e-data-manager>
<e-grid-editSettings allowDeleting="true"></e-grid-editSettings>
<e-grid-columns>
<e-grid-column field="Id" headerText="Id" width="50" isPrimaryKey="true"></e-grid-column>
<e-grid-column field="Alue" headerText="Alue"></e-grid-column>
<e-grid-column field="Lyhenne" headerText="Lyhenne"></e-grid-column>
<e-grid-column field="Paikka" headerText="Paikka"></e-grid-column>
</e-grid-columns>
</ejs-grid>
<script>
function onLoad() {
this.dataSource.dataSource.headers = [{ 'XSRF-TOKEN': $("input:hidden[name='__RequestVerificationToken']").val() }];
}
</script>
Index.cshtml.cs
...
public JsonResult OnPostRemove([FromBody]CRUDModel<Havaintopaikka> value)
{
_context.Havaintopaikat.Remove(value.Value);
return new JsonResult(value);
}