Hello, how are you?
I'm from Brazil, very pleased.
So, I want to press delete, delete also on my backend, not only on my client, I used the destroy method, but it only deletes on the client, it is not deleting from my DB, anyway, where am I wrong?
public IActionResult Delete(Guid? id, [DataSourceRequest] DataSourceRequest request)
{
try
{
var game = UnitOfWork.Game.Get(id);
UnitOfWork.Game.Delete(game);
UnitOfWork.SaveChanges();
return Json(game, request);
}
catch (Exception e)
{
throw new ArgumentException(e.Message);
}
}
And now my Grid:
@(Html.Kendo().Grid<GameListViewModel>()
.Name("Grid")
.Columns(columns =>
{
columns.Bound(p => p.Name).Title("Nome");
columns.Bound(p => p.Price).Title("Preço");
columns.Bound(p => p.Description).Title("Descrição");
columns.Bound(p => p.GenderName).Title("Categoria");
columns.Command(c => c.Edit().HtmlAttributes(new {title = "Editar Item"})).Title("Editar");
columns.Command(read => read.Destroy().HtmlAttributes(new {title = "Deletar item"})).Title("Deletar");
})
.Pageable()
.Sortable()
.Scrollable()
.Filterable()
.HtmlAttributes(new { style = "height:430px;" })
.DataSource(dataSource => dataSource
.Ajax()
.PageSize(20)
.Read(read => read.Action("TelerikGrid", "Game"))
.Update(read => read.Action("Edit", "Game", new {id = "{0}"}))
.Destroy(read => read.Action("Delete", "Game"))
))
Probably my call is not going to the controller, how can I resolve it? Thank you.
I'm from Brazil, very pleased.
So, I want to press delete, delete also on my backend, not only on my client, I used the destroy method, but it only deletes on the client, it is not deleting from my DB, anyway, where am I wrong?
public IActionResult Delete(Guid? id, [DataSourceRequest] DataSourceRequest request)
{
try
{
var game = UnitOfWork.Game.Get(id);
UnitOfWork.Game.Delete(game);
UnitOfWork.SaveChanges();
return Json(game, request);
}
catch (Exception e)
{
throw new ArgumentException(e.Message);
}
}
And now my Grid:
@(Html.Kendo().Grid<GameListViewModel>()
.Name("Grid")
.Columns(columns =>
{
columns.Bound(p => p.Name).Title("Nome");
columns.Bound(p => p.Price).Title("Preço");
columns.Bound(p => p.Description).Title("Descrição");
columns.Bound(p => p.GenderName).Title("Categoria");
columns.Command(c => c.Edit().HtmlAttributes(new {title = "Editar Item"})).Title("Editar");
columns.Command(read => read.Destroy().HtmlAttributes(new {title = "Deletar item"})).Title("Deletar");
})
.Pageable()
.Sortable()
.Scrollable()
.Filterable()
.HtmlAttributes(new { style = "height:430px;" })
.DataSource(dataSource => dataSource
.Ajax()
.PageSize(20)
.Read(read => read.Action("TelerikGrid", "Game"))
.Update(read => read.Action("Edit", "Game", new {id = "{0}"}))
.Destroy(read => read.Action("Delete", "Game"))
))
Probably my call is not going to the controller, how can I resolve it? Thank you.