This is a migrated thread and some comments may be shown as answers.

Kendo UI Grid Delete Action not firing after adding new record (ASP.NET MVC)

4 Answers 851 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Adam
Top achievements
Rank 1
Adam asked on 18 Dec 2014, 07:36 PM
When I create new record in grid and after that I delete that row, delete action method is not requested by client side as I see in firebug and Delete action doesnt fire. What should I do with this?

My grid:

<code>

@(Html.Kendo().Grid<TelerikMvcApp2.Models.Car>()
    .Name("grid")
    .Columns(c=>
    {
        c.Bound(x=>x.Name);
        c.Bound(x=>x.Model);
        c.Bound(x => x.YearOfProduction);
        c.Bound(x => x.Cena);
        c.Command(cmd => cmd.Edit());
        c.Command(cmd => cmd.Destroy());
    })
    .ToolBar(toolbar=>toolbar.Create())
    .Sortable()
    .Editable(e=>e.Mode(GridEditMode.PopUp))
    .Filterable()    
    .DataSource(d=>d
    .Ajax()
    .Model(m=>m.Id(p=>p.Id))
    .Read("GetCars","Home")
    .Destroy("Delete","Home")
    .Create("Create","Home")
    .Update("UpdateCar","Home")
    )
    )

</code>
 
My delete Action:

<code>

 [AcceptVerbs(HttpVerbs.Post)]
        public ActionResult Delete([DataSourceRequest] DataSourceRequest request, Car car)
        {

            return Json(new[] { car }.ToDataSourceResult(request, ModelState));
        }

</code>     






4 Answers, 1 is accepted

Sort by
0
Alexander Popov
Telerik team
answered on 22 Dec 2014, 12:00 PM
Hello Adam,

This could happen if the Create controller does not return a proper response, which in turn will prevent the DataSource from updating the isNew status of the item. Would you please share the related server-side code and also check the browser's console and network tabs for any errors or failed requests?

Regards,
Alexander Popov
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
0
Michael
Top achievements
Rank 1
answered on 16 Oct 2017, 08:38 AM

Hi

I have the same issue and this is my action for create new record.

my action return the same result like in the kendo website but the I still have the problem/

here is my code:

 [AcceptVerbs(HttpVerbs.Post)]
        public ActionResult CreateProduct([DataSourceRequest] DataSourceRequest request, ProductViewModel product)
        {
            if (product != null && ModelState.IsValid)
            {
                var productToAdd = product.Map<ProductViewModel, TaskManagement.Data.Product>();
                m_Repository.Add(productToAdd);
                m_Repository.Save();
            }

            return Json(new[] { product }.ToDataSourceResult(request, ModelState));
        }

thank you

0
Stefan
Telerik team
answered on 18 Oct 2017, 06:29 AM
Hello, Michael,

If the Grid receives the expected response from the Create action, the record should be successfully shown in the Grid after the request.

An issue may occur if the correct ID is not returned in the response.

Please check the following article on the Grid CRUD operations specifics:

https://docs.telerik.com/kendo-ui/framework/datasource/crud#crud-data-operations

If the issue still occurs, please provide a fully runnable example, as the issue can be caused by a custom factor which we are overlooking at this moment.

Regards,
Stefan
Progress Telerik
Try our brand new, jQuery-free Angular components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
0
Michael
Top achievements
Rank 1
answered on 18 Oct 2017, 10:49 AM

It helped me a lot .

I forgot to send the Id of the row.

Thanks

Tags
Grid
Asked by
Adam
Top achievements
Rank 1
Answers by
Alexander Popov
Telerik team
Michael
Top achievements
Rank 1
Stefan
Telerik team
Share this question
or