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

5 posts, 0 answers
  1. Adam
    Adam avatar
    1 posts
    Member since:
    Dec 2014

    Posted 18 Dec 2014 Link to this post

    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>     






  2. Alexander Popov
    Admin
    Alexander Popov avatar
    1443 posts

    Posted 22 Dec 2014 Link to this post

    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!
     
  3. Michael
    Michael avatar
    50 posts
    Member since:
    May 2014

    Posted 16 Oct 2017 Link to this post

    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

  4. Stefan
    Admin
    Stefan avatar
    2491 posts

    Posted 18 Oct 2017 Link to this post

    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.
  5. Michael
    Michael avatar
    50 posts
    Member since:
    May 2014

    Posted 18 Oct 2017 in reply to Stefan Link to this post

    It helped me a lot .

    I forgot to send the Id of the row.

    Thanks

Back to Top