swankyprogramming
swankyprogramming

Reputation: 107

Kendo UI Child Grid -> Destroy Confirmation Firing Twice on Cancel

I have a grid which has a child/sub Grid. It works fine, I can add and remove. However, when I attempt to run the command.destroy, should I press Cancel on the confirmation, it fires again (so I have to press Cancel again). If I choose Confirm, it doesn't popup again and does delete it on first try.

I am unsure whats causing this and I don't think it's my CSHTML but just need a second opinion.

@(Html.Kendo().Grid<ModelA>()
.Name("Grid")

.Columns(columns => 
{
    columns.Bound(o => o.ID).Width(50);
    columns.Bound(o => o.Name).Width(300);
    columns.Bound(o => o.UpdateUser).Width(100);
    columns.Bound(o => o.UpdateDate).Format("{0:d}").Width(100);
    columns.Command(command => { command.Edit(); command.Destroy(); });

})
.ToolBar(toolbar => toolbar.Create())
.ClientDetailTemplateId("adTemplate")
.Pageable()
.Editable(editable => editable.Mode(GridEditMode.PopUp).TemplateName("RoleTemplate"))
.DataSource(dataSource => dataSource
    .Ajax()
    .Read(read => read.Action("RoleRead", "Role"))
    .Update(update => update.Action("RoleUpdate", "Role"))
    .Create(create => create.Action("RoleCreate", "Role"))
    .Destroy(destroy => destroy.Action("RoleRemove", "Role"))
    .PageSize(10)
    .Model(model => 
    {
        model.Id(c => c.ID);
        model.Field(c => c.UpdateUser).Editable(false).DefaultValue(Context.User.Identity.Name);
        model.Field(c => c.UpdateDate).Editable(false).DefaultValue(DateTime.Now);
    })   
    )
.Sortable()
.Filterable()
)  

<script id="adTemplate" type="text/kendo-tmpl">
    @(Html.Kendo().Grid<ModelAChild>()
            .Name("Roles_#=ID#")
            .Columns(columns =>
            {
                columns.Bound(s => s.ActiveDirectoryGroup).Width(500);
                columns.Command(command => { command.Destroy(); });
            })
            .ToolBar(toolbar => toolbar.Create())
            .Editable(editable => editable.Mode(GridEditMode.PopUp).TemplateName("RoleSecurityTemplate"))
            .DataSource(dataSource => dataSource
                .Ajax()
                .Read(read => read.Action("RoleReadSecurity", "Role", new { roleID = "#=ID#" }))
                .Create(create => create.Action("RoleAddSecurity", "Role", new { roleID = "#=ID#" }))
                .Destroy(destroy => destroy.Action("RoleRemoveSecurity", "Role", new { roleID = "#=ID#" }))
                .Model(model => 
                    {
                        model.Id(s => s.ID);
                        model.Field(s => s.UpdateUser).Editable(false).DefaultValue(Context.User.Identity.Name);
                        model.Field(s => s.UpdateDate).Editable(false).DefaultValue(DateTime.Now);
                    })    
                    )
            .Pageable()
            .Sortable()
            .ToClientTemplate())
</script>

Upvotes: 1

Views: 1741

Answers (1)

Petur Subev
Petur Subev

Reputation: 20223

Update your version to the latest one. This was fixed some releases ago.

Upvotes: 1

Related Questions