@(Html.EJ().TreeGrid("TreeGridcontainer")
.ClientSideEvents(eve =>
{
eve.EndEdit("endEditAction");
eve.ActionComplete("completeAction");
})
<script>
function endEditAction(args){
var data = args.data.item; // affected record when edit
$.ajax({
type: "POST",
url: '/TreeGrid/Update',
contentType: "application/json; charset=utf-8",
data: JSON.stringify(data),
dataType: "json",
success: function (result) {
}
})
},
Function completeAction(args) {
if (args.requestType == "addNewRow") {
var data = args.addedRow.item; // Affected record while adding
$.ajax({
type: "POST",
url: '/TreeGrid/Add',
contentType: "application/json; charset=utf-8",
data: JSON.stringify(data),
dataType: "json",
success: function (result) {
},
});
}
else if (args.requestType == "delete") {
//Triggered on delete action
var data = args.data.item; // affected record when delete
$.ajax({
type: "POST",
url: '/TreeGrid/Delete',
contentType: "application/json; charset=utf-8",
data: JSON.stringify(data),
dataType: "json",
success: function (result) {
},
});
}
}); |