I am trying to delete a record using the code generated during the scaffolding process. I take the basic table layout replace it with your grid and bind my model to the grid. See code below:
<ej-grid id="FlatGrid" allow-sorting="true" allow-paging="true">
<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-datamanager json="(IEnumerable<object>)Model" update-url="/MedHistories/Edit" insert-url="/MedHistories/Create" remove-url="/MedHistories/Delete" adaptor="remoteSaveAdaptor"/>
<e-columns >
<e-column field="IdRecordMedHistory" is-primary-key="true" header-text="Id Record" text-align="Left" width="75" header-text-align="TextAlign.Center"></e-column>
<e-column field="DonorId" header-text="Donor ID" text-align="Left" width="75" header-text-align="TextAlign.Center"></e-column>
<e-column field="AdmisionDate" header-text="Admision Date" text-align="Center" format="{0:MM/dd/yyyy}" width="80" header-text-align="TextAlign.Center"></e-column>
<e-column field="DonorHospitalName" header-text="Donor Hospital Name" text-align="Left" width="75" header-text-align="TextAlign.Center"></e-column>
<e-column field="Age" header-text="Age" text-align=Left width="75" header-text-align="TextAlign.Center"></e-column>
<e-column header-Text="Manage Records" width="100">
<e-column-commands>
<e-column-command type="edit">
<e-button-options content-type="TextOnly" text="Edit"></e-button-options>
</e-column-command>
<e-column-command type="delete">
<e-button-options content-type="TextOnly" text="Delete"></e-button-options>
</e-column-command>
<e-column-command type="save">
<e-button-options content-type="TextOnly" text="Save"></e-button-options>
</e-column-command>
<e-column-command type="cancel">
<e-button-options content-type="TextOnly" text="Cancel"></e-button-options>
</e-column-command>
</e-column-commands>
</e-column>
</e-columns>
</ej-grid>
The server side generated code look like this:
public async Task<IActionResult> Delete(long? id)
{
if (id == null)
{
return NotFound();
}
var medHistory = await _context.MedHistory.SingleOrDefaultAsync(m => m.IdRecordMedHistory == id);
if (medHistory == null)
{
return NotFound();
}
return View(medHistory);
}
Using the tabular layout generated during scaffolding the following tag helpers were generated and it works.
<a asp-action="Delete" asp-route-id="@item.IdRecordMedHistory">Delete</a>
I have to be missing something in the configuration of the grid. Because it is not executing any of the crud operations. I want to replicate the functionality :
<a asp-action="Delete" asp-route-id="@item.IdRecordMedHistory">Delete</a> using your grid methods without changing the generated code. Is that possible?
Thanks in advance.