我有一个非常简单的设置,一个名为 #list 的网格,其中的数据源填充了要显示的记录。
我在每一行都有一个按钮,其中有一个调用此函数的 onClick 事件:
// Soft-Delete person
var processURL = crudServiceBaseUrl + '?method=deletePerson';
function deletePerson(id){
if (confirm('#getResource("person.detail.confirmdel")#')) {
$.ajax({
type: 'POST',
url: processURL,
data: {
PERS_KY: id
},
success: function (data){
var thingToDelete = "tr:eq("+id+")";
var grid = $("#list").data("kendoGrid");
grid.removeRow(thingToDelete);
},
error: function (xhr, textStatus, errorThrown){
alert("Error while deleting person"+ "\n"+ xhr + "\n"+ textStatus + "\n" + errorThrown);
}
});
}
}
The server-side stuff works fine, the interaction with the database is good. However, the row does not disappear from the grid.
Anyone?
==============================================================================
In answer to the comments below, here is the revised function:
var processURL = crudServiceBaseUrl + '?method=deletePerson';
function deletePerson(id, row){
if (confirm('#getResource("person.detail.confirmdel")#')) {
$.ajax({
type: 'POST',
url: processURL,
data: {
PERS_KY: id
},
success: function (data){
var thingToDelete = row;
var grid = $("#list").data("kendoGrid");
grid.removeRow(thingToDelete);
},
error: function (xhr, textStatus, errorThrown){
alert("Error while soft-deleting person"+ "\n"+ xhr + "\n"+ textStatus + "\n" + errorThrown);
}
});
}
}
这一切都工作正常,数据库已填充,并且 grid.removeRow() 使行淡出,但随后页面重新加载,这是我不想要的。
知道如何停止页面重新加载吗?