Author Topic: Cancel remote paging and filtering  (Read 1978 times)

cmcooper

  • Newbie
  • *
  • Posts: 5
    • View Profile
Cancel remote paging and filtering
« on: September 20, 2016, 07:50:26 pm »
I have added an alert to the dataModel to cancel going to the next page and filtering if there is unsaved data in the grid.

Code: [Select]
beforeSend: function(jqXHR, settings){
                    if(pageHasChanges){
                        var answer = confirm("Unsaved changes will be lost!");

                        if(!answer){
                            grid.hideLoading();
                            return false;
                        }
}

Everything works correctly except the page number is still incremented even though the paging was canceled. Is there a way to stop the increment from happening?

paramvir

  • Administrator
  • Hero Member
  • *****
  • Posts: 6210
    • View Profile
Re: Cancel remote paging and filtering
« Reply #1 on: September 20, 2016, 08:05:53 pm »
I'm not clear in what kind of scenario you want to cancel remote paging and filtering together.

cancel paging is used in this example.

http://paramquery.com/pro/demos/editing

Code: [Select]
//check the changes in grid before navigating to another page or refresh data.
        grid.pager().on("beforeChange beforeRefresh", function (evt, ui) {
            if (grid.isDirty()) {
                var ans = window.confirm("There are unsaved changes. Are you sure?");
                if (!ans) {
                    return false;
                }
            }
        });