Commit af7aab3a authored by Ad Schellevis's avatar Ad Schellevis

(bootgrid) return to current page after action, for https://github.com/opnsense/core/issues/1303

parent feb11e59
......@@ -80,6 +80,19 @@ function stdBootgridUI(obj, sourceUrl, options) {
return grid;
}
/**
* reload bootgrid, return to current selected page
*/
function std_bootgrid_reload(gridId) {
var currentpage = $("#"+gridId).bootgrid("getCurrentPage");
$("#"+gridId).bootgrid("reload");
// absolutely not perfect, bootgrid.reload doesn't seem to support when().done()
setTimeout(function(){
$('#'+gridId+'-footer a[data-page="'+currentpage+'"]').click();
}, 400);
}
/**
* creates new bootgrid object and links actions to our standard templates
* uses the following data properties to define functionality:
......@@ -135,7 +148,7 @@ $.fn.UIBootgrid = function (params) {
saveFormToEndpoint(url=gridParams['set']+uuid,
formid='frm_' + editDlg, callback_ok=function(){
$("#"+editDlg).modal('hide');
$("#"+gridId).bootgrid("reload");
std_bootgrid_reload(gridId);
}, true);
} else {
console.log("[grid] action set missing")
......@@ -169,7 +182,7 @@ $.fn.UIBootgrid = function (params) {
saveFormToEndpoint(url=gridParams['add'],
formid='frm_' + editDlg, callback_ok=function(){
$("#"+editDlg).modal('hide');
$("#"+gridId).bootgrid("reload");
std_bootgrid_reload(gridId);
}, true);
} else {
console.log("[grid] action add missing")
......@@ -207,7 +220,7 @@ $.fn.UIBootgrid = function (params) {
ajaxCall(url=gridParams['toggle'] + uuid,
sendData={},callback=function(data,status){
// reload grid after delete
$("#"+gridId).bootgrid("reload");
std_bootgrid_reload(gridId);
});
} else {
console.log("[grid] action toggle missing")
......@@ -255,7 +268,7 @@ $.fn.UIBootgrid = function (params) {
});
// refresh after load
$.when.apply(null, deferreds).done(function(){
$("#"+gridId).bootgrid("reload");
std_bootgrid_reload(gridId);
});
}
});
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment