How to prevent Delete Sucessfully after kendo mesh destruction?

I use Kendo Grid to display data. Now I know how to ask for confirmation of deletion, although the net is kendo. Now I want to display a warning, for example, "Delete successfully" after successfully deleting an entry. How should I do it? Here is my kendo grid code.

    @(Html.Kendo().Grid<RxConnectEntities.DeleteFileDTO>().Name("deleteList")
    .Columns(columns =>
    {
        columns.Bound(p => p.DeleteFaxID).Hidden(true);
        columns.Bound(p => p.FaxName).Width(100).Title("File Name");
        columns.Bound(p => p.PerformedDateTime).Width(75).Title("Archive Date").Format("{0:MM/dd/yyyy}");
        columns.Command(command => { command.Destroy().Text("Move"); }).Width(50);
        columns.Bound(p => p.FilePath).Hidden(true);
    })
    .Editable(editable => editable.Mode(GridEditMode.InLine).DisplayDeleteConfirmation("Are you sure want to Move this Finance File?"))
    .Pageable(p => p.PageSizes(true))
        .Scrollable()
        .Sortable()
        .Selectable(selectable => selectable.Mode(GridSelectionMode.Single).Type(GridSelectionType.Row))
        .Events(events => events.Change("onChange"))
        .Groupable()
    .Filterable(filterable => filterable.Extra(false).Operators(operators => operators.ForString(str => str.Clear().StartsWith("Starts with").Contains("contains").IsEqualTo("Is equal to"))))
    .HtmlAttributes(new { style = "height:738px;" })
        .DataSource(dataSource => dataSource
        .Ajax().ServerOperation(true)
        .PageSize(20)
        .Model(m => m.Id(p => p.DeleteFileID))
        .Read(read => read.Action("GetFileList", "Fax"))
    .Destroy(update => update.Action("MoveFileFromArchiveToQueue", "Operation"))
        ))
+4
source share
2 answers

Change to this:

.Events(events => events.Change("onChange").Remove("YourFunctionForAfterDelete")

Then confirm it ...

An alternative is to create a custom delete command, use ajax and return a successful start / error message in a dialog box, or something similar, which is better, but needs a bit more code and reading.

columns.Command(commands =>
                      {
                          commands.Edit() data items
                          commands.Custom("Delete").Click("DeleteByAJAX"); // The "destroy" command removes data items
                      }).Width(95);
+3
source

. onRequestEnd. , . 1 , 1 1 .

ViewBag , CRUD, .

Viewbag ...

@if (ViewBag.Alert == "Success")
{
<div class="alert alert-success alert-dismissible" role="alert">
    <button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">&times;</span></button>
    <strong>Record has been successfully added.</strong>
</div>
}

@if (ViewBag.Alert == "Deleted")
{
<div class="alert alert-success alert-dismissible" role="alert">
    <button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">&times;</span></button>
    <strong>Record has been successfully deleted.</strong>
</div>
}

@if (ViewBag.Alert == "Updated")
{
<div class="alert alert-success alert-dismissible" role="alert">
    <button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">&times;</span></button>
    <strong>Record has been successfully updated.</strong>
</div>
}

, , , , javascript....

<script>
function onRequestEnd(e)
{
    var operationType = e.type;

    if(operationType == "destroy" || operationType == "create" || operationType == "update")
    {
        location.reload();
    }
}
</script>
+1

Source: https://habr.com/ru/post/1543018/


All Articles