Skip to content

Commit 7ff3487

Browse files
Admin panel - Customer - delete cart item
1 parent 78213f7 commit 7ff3487

File tree

1 file changed

+30
-10
lines changed

1 file changed

+30
-10
lines changed

src/Web/Grand.Web.Admin/Areas/Admin/Views/Customer/Partials/CreateOrUpdate.TabCurrentShoppingCart.cshtml

Lines changed: 30 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ $(document).ready(function () {
5454
}
5555
},
5656
requestEnd: function (e) {
57-
if (e.type == "update") {
57+
if (e.type == "update" || e.type == "destroy") {
5858
this.read();
5959
}
6060
},
@@ -76,7 +76,7 @@ $(document).ready(function () {
7676
},
7777
editable: {
7878
confirmation: true,
79-
mode: "inline"
79+
mode: "incell"
8080
},
8181
toolbar: ["save"],
8282
scrollable: false,
@@ -124,14 +124,34 @@ $(document).ready(function () {
124124
width: 200,
125125
type: "date",
126126
format: "{0:G}"
127-
}, {
128-
command: [
129-
{
130-
name: "destroy",
131-
text: "@Loc["Admin.Common.Delete"]"
132-
}],
133-
width: 200
134-
}]
127+
}, {
128+
title: "@Loc["Admin.Common.Delete"]",
129+
width: 200,
130+
template: "<button class='k-button k-grid-delete' onclick=deleteRow('#=Id#')>Delete</button>"
131+
}]
135132
});
136133
});
134+
135+
function deleteRow(id) {
136+
var grid = $("#currentshoppingcart-grid").data("kendoGrid");
137+
var dataItem = grid.dataSource.get(id);
138+
var tokenInput = $('input[name=__RequestVerificationToken]');
139+
$.ajax({
140+
url: "@Html.Raw(Url.Action("DeleteCart", "Customer", new { customerId = Model.Id, area = Constants.AreaAdmin }))",
141+
type: "POST",
142+
data: {
143+
id: dataItem.Id,
144+
customerId: "@Model.Id",
145+
__RequestVerificationToken: tokenInput.val(),
146+
},
147+
success: function () {
148+
grid.dataSource.remove(dataItem);
149+
grid.dataSource.sync();
150+
},
151+
error: function (e) {
152+
display_kendoui_grid_error(e);
153+
}
154+
});
155+
}
156+
137157
</script>

0 commit comments

Comments
 (0)