Hello,
i've implemented a custom comand delete-button for inline-editing. if clicked, a popup fades in and i have the choice to click "yes" or "no" for delete confirmation.
but on controller the delete-event is triggered twice and throws errors. what is wrong with my code? hope you can help me.
Grid:
Javascript:
Thanks for help! :)
i've implemented a custom comand delete-button for inline-editing. if clicked, a popup fades in and i have the choice to click "yes" or "no" for delete confirmation.
but on controller the delete-event is triggered twice and throws errors. what is wrong with my code? hope you can help me.
Grid:
@(Html.Kendo().Grid(Model)
.Name(
"Adressen"
)
// Datasource
.DataSource(dataSource => dataSource
.Ajax()
.AutoSync(
true
)
.PageSize(250)
.Model(model =>
{
model.Id(p => p.Eadr);
model.Field(p => p.Eadr).Editable(
false
);
model.Field(p => p.BaLand).DefaultValue(
new
LiCPSAdmin2.Models.BaLand());
})
.Events(events => events.Error(
"adressen_error_handler"
))
.Create(create => create.Action(
"Create"
,
"Adressen"
))
.Read(read => read.Action(
"Read"
,
"Adressen"
))
.Update(update => update.Action(
"Edit"
,
"Adressen"
))
.Destroy(destroy => destroy.Action(
"Delete"
,
"Adressen"
))
)
//Columns
.Columns(columns =>
{
columns.Command(command =>
{
command.Edit().Text(
" "
);
command.Custom(
" "
).Click(
"adressen_delete_handler"
).HtmlAttributes(
new
{ name =
"btn_delete"
});
}).Width(90).HtmlAttributes(
new
{ style =
"background-color: rgb(238, 238, 238)"
});
columns.Bound(p => p.Eadr).Width(90).HtmlAttributes(
new
{ style =
"text-align:center;"
});
columns.Bound(p => p.Nama);
columns.Bound(p => p.Namb);
columns.Bound(p => p.Namc);
columns.Bound(p => p.Namd);
columns.Bound(p => p.Name);
columns.Bound(p => p.Namf);
columns.Bound(p => p.Pstc).Width(90).HtmlAttributes(
new
{ style =
"text-align:center;"
});
columns.Bound(p => p.Ccty).Width(90).HtmlAttributes(
new
{ style =
"text-align:center;"
});
columns.Bound(p => p.BaLand.Dsca)
.Width(200)
.ClientTemplate(
" #= BaLand ? BaLand.Dsca : '' # "
)
.Filterable(f => f.UI(
"statesFilter"
));
})
// Events
.Events(events => events.Edit(
"adressen_edit_handler"
)
.DataBound(
"adressen_bound_handler"
))
// Options
.ToolBar(toolbar => toolbar.Create().HtmlAttributes(
new
{ enabled =
"false"
}))
.Editable(editable => editable.Mode(GridEditMode.InLine).DisplayDeleteConfirmation(
false
))
.Pageable()
.Sortable()
.Filterable(filter => filter.Extra(
false
))
.Scrollable(scrollable => scrollable.Virtual(
true
))
.HtmlAttributes(
new
{ style =
"height:100%;"
})
.Resizable(resize => resize.Columns(
true
))
.ColumnResizeHandleWidth(5)
.Reorderable(reordering => reordering.Columns(
false
))
)
function
adressen_delete_handler(e) {
e.preventDefault();
var
grid =
this
;
var
row = $(e.currentTarget).closest(
"tr"
);
$(
"#delete_confirmation_popup"
).css({
'top'
: ($(row).position().top + 157 + ($(row).height() / 2)),
'margin-left'
: (86)}).fadeIn();
$(
"#btn_yes"
).off().on(
'click'
,
function
() {
grid.removeRow(row);
$(
"#delete_confirmation_popup"
).fadeOut();
});
$(
"#btn_no"
).off().on(
'click'
,
function
() {
grid.cancelChanges();
$(
"#delete_confirmation_popup"
).fadeOut();
});
};