Like the title says, my grid doesn't "call home" on row deletion... read/update/create work just fine (and all go to the same .aspx on the server).
Here's my (edited slightly) code:
var sThisPage = location.pathname.substring(location.pathname.lastIndexOf("/") + 1);
$("#divGrid").kendoGrid({
columns: [
{
field: 'Department1',
title: 'Department',
width: 100,
editable: telerik_grid_column_onEditable,
editor: deptDropDownEditor,
template: "${displayDept(Department1)}",
},
{
field: 'EmployeeID',
title: 'Employee',
width: 200,
editable: telerik_grid_column_onEditable,
editor: emplDropDownEditor,
template: "${displayEmpl(EmployeeID)}",
},
{
field: 'SecurityLevel',
title: 'Security level',
width: 100
},
{
field: 'EmplActive',
title: 'Active',
width: 80,
template: "#= EmplActive ? '<span class=\"fa-solid fa-check\"></span>' : '' #"
},
],
dataSource: new kendo.data.DataSource({
serverPaging: false,
serverFiltering: false,
serverSorting: false,
//autoSync: true,
requestStart: function (telerikEvent) {
},
requestEnd: function (telerikEvent) {
},
sync: function (telerikEvent) {
var oToolbar = $("#divToolbar").data("kendoToolBar");
var oFirstLine = this._data[0];
if (!oFirstLine.ID || oFirstLine.ID == '') { //First line is a new recordif ((!oFirstLine.Department1 || oFirstLine.Department1 == '')
|| (!oFirstLine.EmployeeID || oFirstLine.EmployeeID == '')
|| (!oFirstLine.SecurityLevel || oFirstLine.SecurityLevel == '' || oFirstLine.SecurityLevel == 0)) {
alert('New line not saved as some values are missing.');
}
}
oToolbar.enable("#btnSave", false);
oToolbar.enable("#btnCancel", false);
},
error: function (e) {
if (e.xhr) {
alert(e.xhr.responseText);
}
$("#divGrid").data("kendoGrid").cancelChanges();
},
transport: {
read: {
url: sThisPage,
type: "POST",
dataType: "json",
cache: false,
data: { action: "R" }
},
update: {
url: sThisPage,
type: "POST",
dataType: "json",
cache: false,
data: { action: "U" }
},
create: {
url: sThisPage,
type: "POST",
dataType: "json",
cache: false,
data: { action: "C" }
},
destroy: {
url: sThisPage,
type: "POST",
dataType: "json",
cache: false,
data: { action: "D" }
},
},
schema: {
model: {
id: "ID",
fields: {
Department1: {
type: "number"
},
EmployeeID: {
type: "number"
},
DeptName: {
type: "string"
},
EmployeeName: {
type: "string"
},
SecurityLevel: {
type: "number",
validation: { required: true, min: 1, max: 100 }
},
EmplActive: {
type: "boolean",
editable: false
},
}
}
},
}),
editable: true,
sortable: true,
selectable: "row",
change: telerik_grid_onChange,
beforeEdit: telerik_grid_onBeforeEdit,
edit: telerik_grid_onEdit,
cellClose: telerik_grid_onCellClose,
remove: function (telerikEvent) {
var x = telerikEvent;
this.dataSource.sync();
},
});
function telerik_toolbar_button_onClick(telerikEvent) {
var x = telerikEvent;
var oGrid = $("#divGrid").data("kendoGrid");
switch (telerikEvent.id) {
/*snip*/
case 'btnDelete':
var oSelected = oGrid.select();
oGrid.removeRow(oSelected);
break;
}
} //telerik_toolbar_button_onClick
If I set breakpoints on the requestStart and requestEnd functions in the data source and delete a line, neither gets hit.
Am I doing something wrong?