質問

剣道グリッドを使用してデータを表示しています。今、剣道グリッドをむだに削除の確認を尋ねる方法を知っています。これで、RECORDのSUCESSFULL削除後にDELETEのようなアラートを正常に表示したい。どうやってやることができますか?これが私の剣道グリッドコードです。

    @(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"))
        ))
.

役に立ちましたか?

解決

これに変更する:

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

その後、それから確認してください...

削除するためのカスタムコマンドを作成する方法は、Ajaxを使用して、成功/エラーメッセージをダイアログまたは似ているものに返します。これは、より良いがもう少しコードと読み取りをします。

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

他のヒント

私は上記の方法を試してみて、必要に応じて働くことができませんでした。代わりにOnRequestendメソッドを購読しました。投げる必要があるいくつかの警告メッセージがありました。1レコードを正常に追加するために、レコードを正常に削除するための1、およびレコードの更新を正常に更新するための1。

私は発生していた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>
.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top