Delete does not appear to work on Scaffolded Controller using Sqlite Database

Hi All,

I have just started with Syncfusion Controls and followed the "Scaffolding" process for a Sqlite Database using Blazor.

This generated both the "DataPage" & the "Controller", but does not appear to have generated a "Delete" method in the Controller.

When I click the "Delete" button in the page, nothing appears to happen.

This is the code for my Page:

@page "/EmuTypeDataGrid"
@using EmulatorDatabase.Shared.Models;
@using Syncfusion.Blazor.Data;
@using Syncfusion.Blazor;
@using Syncfusion.Blazor.Grids;

<SfGrid ID="Grid" @ref="@Grid" TValue="EmuType" Height="315" AllowSorting="true" AllowPaging="true"  Toolbar="@(new List<string>() { "Search", "Add", "Edit", "Delete", "Update", "Cancel"})" AllowFiltering="true" AllowSelection="true">
    <SfDataManager Url="/api/EmuType" RemoveUrl="/api/EmuType/Delete" InsertUrl="/api/EmuType/Insert" UpdateUrl="/api/EmuType/Update" Adaptor="Adaptors.UrlAdaptor" ></SfDataManager>
    <GridPageSettings PageSize="10"></GridPageSettings>
    <GridFilterSettings Type="Syncfusion.Blazor.Grids.FilterType.FilterBar"></GridFilterSettings>
    <GridEditSettings AllowAdding="true" AllowDeleting="true" AllowEditing="true" Mode="EditMode.Normal"></GridEditSettings>
    <GridColumns>
        <GridColumn Field="Name" HeaderText="System Type" Type="ColumnType.String" ValidationRules="@(new ValidationRules{ Required=true})"></GridColumn>
    </GridColumns>
</SfGrid>

@code{
    SfGrid<EmuType>  Grid { get; set; }
}
 
And this is the code for my Controller:

using System.Collections;
using System.Collections.Generic;
using Syncfusion.Blazor;
using Newtonsoft.Json;
using System.Linq;
using System;
using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore;
using EmulatorDatabase.Shared.Models;

namespace EmulatorDatabase.Server.Controllers
{
    public class EmuTypeController : ControllerBase
    {
        private readonly EmuDbContext db;

        public EmuTypeController(EmuDbContext _db)
        {
            db = _db;
        }

public DbSet<EmuType> GetAll()
        {
try
{
return db.EmuType;
}
catch
{
throw;
}
        }
              
       // POST api/<controller>
        [HttpPost]
        [Route("api/[controller]")]
        public Object Post([FromBody]DataManagerRequest dm)
        {
            IEnumerable DataSource = GetAll().ToList();

            if (dm.Search != null && dm.Search.Count > 0)
            {
                DataSource = DataOperations.PerformSearching(DataSource, dm.Search);  //Search
            }
            
            if (dm.Sorted != null && dm.Sorted.Count > 0) //Sorting
            {
                DataSource = DataOperations.PerformSorting(DataSource, dm.Sorted);
            }
            
            if (dm.Where != null && dm.Where.Count > 0) //Filtering
            {
                DataSource = DataOperations.PerformFiltering(DataSource, dm.Where, dm.Where[0].Operator);
            }
            
            int count = DataSource.Cast<EmuType>().Count();
            
            if (dm.Skip != 0)
            {
                DataSource = DataOperations.PerformSkip(DataSource, dm.Skip);   //Paging
            }
            
            if (dm.Take != 0)
            {
                DataSource = DataOperations.PerformTake(DataSource, dm.Take);
            }
           
            return dm.RequiresCounts ?  new { result = DataSource, count = count } : DataSource as object;
        }
        [HttpPost]
        [Route("api/EmuType/Insert")]
        public void Insert([FromBody]CRUDModel<EmuType> EmuType)
        {
            try
            {
                db.EmuType.Add(EmuType.Value);
                db.SaveChanges();
            }
            catch
            {
                throw;
            }
        }
        
        [HttpPost]
        [Route("api/EmuType/Update")]
        public void UpdateOrder([FromBody]CRUDModel<EmuType> EmuType)
        {
            try
            {
                db.Entry(EmuType.Value).State = EntityState.Modified;
                db.SaveChanges();
            }
            catch
            {
                throw;
            }
        }
       
        public class CRUDModel<T> where T : class
        {
[JsonProperty("action")]
            public string Action { get; set; }
            [JsonProperty("table")]
            public string Table { get; set; }
            [JsonProperty("keyColumn")]
            public string KeyColumn { get; set; }
            [JsonProperty("key")]
            public object Key { get; set; }
            [JsonProperty("value")]
            public T Value { get; set; }
            [JsonProperty("added")]
            public List<T> Added { get; set; }
            [JsonProperty("changed")]
            public List<T> Changed { get; set; }
            [JsonProperty("deleted")]
            public List<T> Deleted { get; set; }
            [JsonProperty("params")]
            public IDictionary<string, object> Params { get; set; }
        }
}    
}

Any help would be greatly appreciated.

Thanks in advance.

Shando

1 Reply 1 reply marked as answer

JP Jeevakanth Palaniappan Syncfusion Team August 17, 2020 12:58 PM UTC

Hi Simon, 
 
Greetings from Syncfusion Support. 
 
We have confirmed it is a bug and logged the defect report “Delete method is not auto-generated (Scaffolded) for DataGrid” for the same. The reported issue will be fixed as soon as possible. We have a weekly patch release where the latest Nuget (Syncfusion.Blazor) will be published in Nuget.org site comprising the fix for several issues. But since this fix has to be included in the Visual Studio Extension. It will be included in our next Main release(2020 Volume 3) which is expected to be rolled out by end of September 2020. 
 
You can now track the current status of your request, review the proposed resolution timeline, and contact us for any further inquiries through below links 
 
 
Until then we appreciate your patience. 
 
Regards, 
Jeevakanth SP. 


Marked as answer
Loader.
Up arrow icon