Reputation: 299
I have a grid with list items. I have an option to delete certain selected items. However I have a problem.
When I have multiple items, they all disappear after they were deleted. But when I have 1 item left, and I delete it, the stored procedure is run and everything is deleted. But visually the list item is still there. However if I refresh my page it is gone.
I need it to disappear like the others after delete. I have my two functions here. One is the delete and refresh. And the other is the refresh code.
Here is my grid:
$('#viewExpensesGrid').flexigrid({
url: url,
dataType: 'json',
method: 'get',
colModel: [
{ display: '<input type="ch etc etc other parts of table like id, name etc
Here is my delete:
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.
},
and here is the refresh code:
$.fn.flexReload = function (p) { // function to reload grid
return this.each(function () {
if (this.grid && this.p.url) this.grid.populate();
});
Upvotes: 1
Views: 369
Reputation: 1487
I realise this is an old thread, but I ran into this very same issue with the flexigrid caching the results and not refetching the data via Ajax. It appears to not yet be fully resolved in the implementation.
My "hack" is to slightly modify the URL when I call .flexReload()
such that it adds a random value to the query string:
$("#grid").flexOptions({ url: 'server_url?hash=' + Math.random()}).flexReload();
This resolved the issue for me.
Upvotes: 0
Reputation: 78
Are you using the latest version of flexigrid?
Looks like there was a possible fix committed in August.
See $.ajax cache fix for flexReload()
Upvotes: 1