How to delete row programatically?

2 posts, 0 answers
  1. Grzegorz
    Grzegorz avatar
    1 posts
    Member since:
    Sep 2012

    Posted 23 Aug 2013 Link to this post

    I want to change confirmation popup from synchronous browser popup to asynchronous popup (alertify). I found some old threads in Telerik MVC Extensions (http://www.telerik.com/community/forums/aspnet-mvc/grid/delete-a-row-programmatically.aspx), but this code is not working for me.

    How can I delete row programatically?
    I already attached to Delete event and prevent remove row, but I can't remove it programatically on positive confirmation callback (callback was called but nothing happens).

    How prevent deleting row in client side too? - return false or e.preventDefault cancel remote delete call but row was removed from view.

    Here is my javascript delete handler code:
    function deleteRow(e) {/* How prevent delete row in client side too - return false or e.preventDefault cancel remote delete call but row was removed from view */
        alertify.confirm("dddd", function(result) {
            if (result) {
                e.sender.removeRow(e.row); /* not removing row */
            }
        });
        return false;
    }
    Here is grid MVC builder code:
    @(Html.Kendo().Grid(Model.Franchises)
                         .Name("franchisesGrid")
                         .Columns(columns =>
                                      {
                                          columns.Bound(p => p.Name);
                                          columns.Bound(p => p.CompanyName);
                                          columns.Command(command =>
                                                              {
                                                                  command.Edit().Text(LocalizationResources.Update).CancelText(LocalizationResources.Cancel).UpdateText(LocalizationResources.OK);
                                                                  command.Destroy().Text(LocalizationResources.Remove);
                                                              });
                                      })
                         .Groupable()
                         .Pageable()
                         .Sortable()
                         .Scrollable()
                         .Filterable()
                         .ColumnMenu()
                         .ToolBar(toolbar =>
                                      {
                                          toolbar.Template(@<text>
                                                                <div class="row control-group">
                                                                    <div class="span10">
                                                                        <a class="btn k-btn-add k-grid-add"><span class="k-icon k-add"></span>@LocalizationResources.Create</a>
                                                                    </div>
                                                                </div>
                                                            </text>);
                                      })
                         .Resizable(resize => resize.Columns(true))
                         .Reorderable(reorder => reorder.Columns(true))
                         .Editable(editable =>
                                       {
                                           editable.Mode(GridEditMode.PopUp).Window(builder => builder.Title("Title"));
                                           editable.DisplayDeleteConfirmation(false);
                                       })
                         .Events(builder => builder.Remove("deleteRow"))
                         .DataSource(dataSource => dataSource
                                                       .Ajax()
                                                       .Events(events => events.Error("error_handler"))
                                                       .Model(model => model.Id(p => p.Id))
                                                       .Read("Get", "Home")
                                                       .Create("Create", "Home")
                                                       .Update("Update", "Home")
                                                       .Destroy("Remove", "Home")))
  2. Alexander Popov
    Admin
    Alexander Popov avatar
    1441 posts

    Posted 27 Aug 2013 Link to this post

    Hi Grzegorz,


    Please note that the required behavior is not supported out-of-the-box and it will require custom solution, however for convenience I created small example which you can use as a baseline to achieve the desired behavior:


    Regards,
    Alexander Popov
    Telerik
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
Back to Top