Hello
I am using ASP.NET CORE EJ 2 version 16.3.0.27, Microsoft.AspNetCore.MVC and Microsoft.EntityFrameworkCore .
Using the grid with the UrlAdaptor.
When editing records, the
corresponding url action is called correctly and the update works fine,
but at insert the param / value is always null or empty.
Could you provide me to solve this problem?
[View]
@model IEnumerable<AWT_Admin.Models.TblMasterBuilding>
<ejs-grid id="Grid_Buildings" toolbar="@(new List<string>() { "Add", "Edit", "Update", "Delete", "Cancel", "Search" })" actionComplete="onActionComplete" allowPaging="true" allowSorting="true" allowFiltering="false" allowGrouping="false">
<e-data-manager url="/TblMasterBuildings/UrlDatasource" updateUrl="/TblMasterBuildings/RecordUpdate" insertUrl="/TblMasterBuildings/RecordInsert" adaptor="UrlAdaptor"></e-data-manager>
<e-grid-pagesettings pageCount="5" pageSizes="@(new string[] { "12", "24", "48" , "All" })"></e-grid-pagesettings>
<e-grid-editSettings allowAdding="true" allowDeleting="true" allowEditing="true" showDeleteConfirmDialog="true"></e-grid-editSettings>
<e-grid-columns>
<e-grid-column field="BuildingId" headerText="Gebäude ID" allowEditing="false" isPrimaryKey="true" isIdentity="true" textAlign="Right" width="120"></e-grid-column>
<e-grid-column field="Building" headerText="Gebäude" width="150"></e-grid-column>
<e-grid-column field="Active" headerText="Aktiv" displayAsCheckBox="true" type="boolean" editType="booleanedit" minWidth="8" width="120"></e-grid-column>
</e-grid-columns>
</ejs-grid>
<script>
function onActionComplete(args) {
if (args.requestType === "delete" || args.requestType === "save") {
this.refresh();
}
};
</script>
[Model]
public partial class TblMasterBuilding
{
public TblMasterBuilding()
{
}
/// <summary>
/// Initializes a new instance of the <see cref="TblMasterBuilding"/> class.
/// </summary>
public TblMasterBuilding(int BuildingId, string Building, bool? Active)
{
this.BuildingId = BuildingId;
this.Building = Building;
this.Active = Active;
TblLocation = new HashSet<TblLocation>();
}
[Key]
public int BuildingId { get; set; }
public string Building { get; set; }
public bool? Active { get; set; }
public ICollection<TblLocation> TblLocation { get; set; }
}
[Contoller]
using System.Linq;
using System.Collections.Generic;
using System.Threading.Tasks;
using System.Collections;
using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore;
using AWT_Admin.Models;
using Syncfusion.EJ2.Base;
using Newtonsoft.Json;
public IActionResult RecordUpdate([FromBody]CRUDModel<TblMasterBuilding> param)
{
_context.Entry(param.Value).State = EntityState.Modified;
_context.SaveChanges();
return Json(param);
}
public IActionResult RecordInsert([FromBody]CRUDModel<TblMasterBuilding> param)
{
_context.Add(param);
_context.SaveChanges();
return Json(param);
}
Also a complete CRUD example for AspNetCore.Mvc,
EntityFrameworkCore and the current Syncfusion.EJ2.Base
including
source code for model, view and controller, would be very nice.
Thanks in advance
Christian