我有一个带有列表项的网格。我可以选择删除某些选定的项目。但是我有一个问题。
当我有多个项目时,它们在被删除后都会消失。但是当我还剩下 1 项并将其删除时,存储过程将运行并删除所有内容。但从视觉上看,列表项仍然存在。但是,如果我刷新我的页面,它就消失了。
我需要它在删除后像其他人一样消失。我在这里有两个功能。一是删除和刷新。另一个是刷新代码。
这是我的网格:
$('#viewExpensesGrid').flexigrid({
url: url,
dataType: 'json',
method: 'get',
colModel: [
{ display: '<input type="ch etc etc other parts of table like id, name etc
这是我的删除:
function doTheDelete(doIDeleteExpenses) {
var selectedExpensesList = getSelectedExpenseIDs();
if (selectedExpensesList.length > 0) {
$.ajax({
type: "POST",
//url: "/Tasks/ViewTasks.aspx/deleteTasksAndLinkedItems",
url: '<%=ResolveUrl("~/Expenses/ViewExpenses.aspx/deleteSelectedExpense")%>',
data: "{'DeleteExpenses' : '" + doIDeleteExpenses + "'," + "'ExpID': ['" + selectedExpensesList.join(',') + "']}",
//dataaaaaa
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function (data) {
var ss = data.d;
if (ss.length > 0) {
for (var i = 0; i < ss.length; ++i) {
$.noty.consumeAlert({ layout: 'center', type: 'error', dismissQueue: true });
alert(ss[i]);
}
}
$("#viewExpensesGrid").flexReload(); //this reloads the grid but doesnt gets rid of the last item.
},
这是刷新代码:
$.fn.flexReload = function (p) { // function to reload grid
return this.each(function () {
if (this.grid && this.p.url) this.grid.populate();
});