//Refresh Method For Project Spend Grid
function RefreshSpentGrid() {
if ($pfbudgrid != undefined) {
if ($pfbudgrid.pqGrid('getInstance').grid.isDirty()) {
if (confirm('Do you want to save data?')) {
PFSpentSave();
}
}
$("#grid_pfBudjet").pqGrid("destroy");
$pfbudgrid = undefined;
BindPfBudjet();
setScrollling();
Getmatrix();
}
}
/***************************************************************************/
//Refresh Method For Project FTE Grid
function RefreshFteGrid() {
if ($grid != undefined) {
if ($grid.pqGrid('getInstance').grid.isDirty()) {
if (confirm('Do you want to save data?')) {
ExtLabourSave();
}
}
$("#grid_prFte").pqGrid("destroy");
$grid = undefined;
BindPfFte();
setScrollling();
Getmatrix();
}
}
/***************************************************************************/
//Save Method for Project Spend Grid
function PFSpentSave() {
var grid = $("#grid_pfBudjet").pqGrid('getInstance').grid;
if (grid.saveEditCell() === false) {
return false;
}
if (grid.isDirty()) {
var changes = grid.getChanges({ format: "byVal" });
$.ajax({
dataType: "json",
type: "POST",
async: false,
beforeSend: function (jqXHR, settings) {
grid.showLoading();
},
url: '@Url.Action("SavePrSpent")',
data: { list: JSON.stringify(changes), projectId: projectId,year:$("#drpYear").val() },
success: function (changes) {
//debugger;
grid.commit({ type: 'add', rows: changes.addList });
grid.commit({ type: 'update', rows: changes.updateList });
grid.commit({ type: 'delete', rows: changes.deleteList });
grid.history({ method: 'reset' });
alert("Saved Successfully!");
},
complete: function () {
grid.hideLoading();
RefreshSpentGrid();
}
});
}
}
/***************************************************************************/
//Save Method for Project FTE Grid
function ExtLabourSave() {
var grid = $("#grid_prFte").pqGrid('getInstance').grid;
if (grid.saveEditCell() === false) {
return false;
}
if (grid.isDirty()) {
var changes = grid.getChanges({ format: "byVal" });
$.ajax({
dataType: "json",
type: "POST",
async: false,
beforeSend: function (jqXHR, settings) {
grid.showLoading();
},
url: '@Url.Action("SaveExtLabour")',
data: { list: JSON.stringify(changes), projectId: projectId,year:$("#drpYear").val() },
success: function (changes) {
//debugger;
grid.commit({ type: 'add', rows: changes.addList });
grid.commit({ type: 'update', rows: changes.updateList });
grid.commit({ type: 'delete', rows: changes.deleteList });
grid.history({ method: 'reset' });
alert("Saved Successfully!");
},
complete: function () {
grid.hideLoading();
RefreshSpentGrid();
RefreshFteGrid();
}
});
}
}
Note: I need to refresh the first grid on the save of second grid as some calculation is involved in the process.
I don't want both the grid to collapse after saving the second.
If I am saving only the first grid, I am able to keep the rows expanded by not calling the RefreshSpentGrid(); method in the complete block of PFSpentSave() method.