Hi Manisankar,
Unfortunately I am still having issues with the new added item not being shown in the grid after saving . Note that I am using ASP.Net Core.
Below is the code for the View:
<div id="ControlRegion">
<ej-dialog id="ErrorList" title="Error" show-on-init="false" close="onDialogClose"></ej-dialog>
<ej-grid id="FlatGrid" allow-sorting="true" action-failure="OnActionFailure" action-complete="OnActionComplete">
<e-datamanager url="Pricing/Currency/GetList" update-url="Pricing/Currency/Update" insert-url="Pricing/Currency/Insert" adaptor="@AdaptorType.UrlAdaptor"></e-datamanager>
<e-edit-settings allow-adding="true" allow-editing="true" allow-deleting="true"></e-edit-settings>
<e-toolbar-settings show-toolbar="true" toolbar-items='@new List<string> {"add","edit","update","delete","cancel"}' />
<e-columns>
<e-column field="CurrencyID" header-text="ID" is-primary-key ="true" is-identity="true"></e-column>
<e-column field="Code" header-text="Code"></e-column>
<e-column field="Symbol" header-text="Symbol"></e-column>
<e-column field="Prefix" header-text="Prefix"></e-column>
<e-column field="GroupSize" header-text="Group Size" edit-type="Numeric"></e-column>
<e-column field="GroupSeparator" header-text="Group Separator" />
<e-column field="DecimalSeparator" header-text="Decimal Separator" />
<e-column field="ShortName" header-text="Short Name"></e-column>
<e-column field="LongName" header-text="Long Name" ></e-column>
<e-column field="Country" header-text="Country" ></e-column>
<e-column field="IsActive" header-text="Active" edit-type"="Boolean" ></e-column>
<e-column field="Lockstamp" header-text="Lockstamp" visible="false" ></e-column>
</e-columns>
</ej-grid>
</div>
Here is the C# code
public async Task<ActionResult> Insert([FromBody]CRUDModel<mdCurrency> value)
{
var crudMsg = new mdCrudMessage();
if (value.Action == Constants.CrudOperations.LIT_INSERT)
{
var response = await PostWSObjectAsync<mdCurrency, mdCurrencyResponse>(value.Value, URI_RESOURCE);
crudMsg = MessageFormatter.FormatCrudResultsHtml(response.CrudResults);
}
if (crudMsg.IsFault)
return new BadRequestObjectResult(crudMsg.HtmMessage);
return Json(value.Value);
}
The only way I can view the newly inserted row is to resfresh the page by pressing F5, which I want to avoid.
Thanks for your help.
|
public ActionResult NormalInsert([FromBody]CRUDModel<Orders> param)
{
_context.Orders.Add(param.Value); //record to be added in DB
_context.SaveChanges();
var data = _context.Orders.ToList();
return Json(param.Value); //return the added records
} |