Multiple deletes/trying to perform first delete again....

3 posts, 0 answers
  1. Terry
    Terry avatar
    20 posts
    Member since:
    May 2017

    Posted 13 Jul Link to this post


    I've a kendo grid with a delete option for each row. Delete an item and it is removed from the list and the dete from the data context performs successfully. However when I delete another row, it tries to perform the delete of the first deleted row a 2nd time, cant find the entity and throws an error, so the 2nd item is not deleted.

    Code as follows -



            .Columns(columns =>
                columns.Bound(p => p.Id).Title("Id").Visible(false);
                columns.Bound(p => p.Title).Title("Title").Width(100);
                columns.Bound(p => p.AticleTypeDesc).Title("Article Type").Width(100); ;
                columns.Bound(p => p.AticleCodeType).Title("Article Type").Visible(false);
                columns.Bound(p => p.PublishedOn).Format("{0:dd/MM/yyyy HH:mm:ss}").Width(150).Title("Date Published").Width(100);
                columns.Command(command => command.Destroy()).Width(40);
                columns.Template(x => { }).ClientTemplate("<a class='k-button k-button-icontext k-grid-EditArticle' href='" + Url.Action("Edit", new { id = "#= Id #" }) + "'>Edit</a>").Width(30);
            .Events(e => e.DataBound("onRowBound")
            .Filterable(ftb => ftb.Mode(GridFilterMode.Row))
            .DataSource(dataSource => dataSource
                                    .Model(model =>
                                        model.Id(p => p.Id);
                                        model.Field(p => p.Title);
                                    .Read(read => read.Action("DisplayArticlesRead", "Article").Type(HttpVerbs.Get))
                                    .Destroy(destroy => destroy.Action("ArticleDestroy", "Article").Type(HttpVerbs.Post))


    Server-side -


            //public ActionResult ArticleDestroy([DataSourceRequest] DataSourceRequest request, [Bind(Prefix = "models")]IEnumerable<DisplayArticleViewModel> articles)
            public ActionResult ArticleDestroy([DataSourceRequest] DataSourceRequest request, [Bind(Prefix = "models")]IEnumerable<DisplayArticleViewModel> articles)
                if (articles.Any())
                    foreach (var article in articles)
                        // Delete Any Article Attachments first, so as not to leave orphaned records
                        var articleAttachments = _articleRepository.GetArticleAttachments(article.Id);
                        if (articleAttachments.Count > 0)
                            foreach (var articleAttachment in articleAttachments)
                //return Json(articles.ToDataSourceResult(request, ModelState));
                return Json(articles.ToDataSourceResult(request, ModelState));


    I've read up on it and it seems I need to return a success indicator to the grid but I cant work out how to do this in an mvc setup.

    Any help greatly appreciated.



  2. Terry
    Terry avatar
    20 posts
    Member since:
    May 2017

    Posted 14 Jul Link to this post

    Could really do with some help with this. I've tried a number of different approaches now and nothing will work.

    I tried firing the following on the .Remove grid event -


    function refreshList_Remove(e) {


    Again, no luck.

    I've also tried the inline editing option here - inline delete with no success.

    This is incredibly frustrating.



  3. Stefan
    Stefan avatar
    1150 posts

    Posted 17 Jul Link to this post

    Hello Terry,

    From the provided code it seems that the deleted item is not returned to the Grid from the controller.

    Please check the expected format in the CRUD article of the DataSource:

    Also, the Ajax editing page can be helpful in this case:

    Additionally, we have different runnable examples with CRUD operations, where it can be observed how the controller should be set:

    In general, I can suggest inspecting the response from the server once a delete operation is initiated, and observe if there is a difference between the response and the shown format in the documentation.

    If additional assistance is needed, please send a fully runnable example, as the issue can be caused by a custom factor which we are overlooking at this moment.

    Progress Telerik
    Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
Back to Top