EasyUI Forum

General Category => EasyUI for jQuery => Topic started by: lomonmic on January 14, 2020, 02:25:18 AM



Title: Stop the events of pagination
Post by: lomonmic on January 14, 2020, 02:25:18 AM
Hello, sorry if I use an automatic translator, but I don't speak English well.
I would need to stop paging when there is still data to save in datagrid remote.
Is it possible to stop the event and stay on the modified data page?
Thank you.


Title: Re: Stop the events of pagination
Post by: stworthy on January 15, 2020, 01:50:58 AM
Please show some code snippets and describe your question in more detail.


Title: Re: Stop the events of pagination
Post by: lomonmic on January 15, 2020, 02:24:02 AM
Thanks for the reply.
I solved the problem this way (see code below)
but I would have preferred to block the event: onSelectPage. It can be done ?

Michele.

...
...
var pager = dd.datagrid('getPager');
var popts = pager.pagination('options');
var onSelectPage = popts.onSelectPage;
popts.onSelectPage = function(pageNumber, pageSize){
      
    var rows = $('#tt').datagrid('getChanges');
    alert(rows.length+' rows are changed!');
    if(rows.length > 0)
    {
          var rc = confirm('Ci sono records da salvare. Confermi ?');
          if(rc)
          {
            var dataString = JSON.stringify(rows) ;
            var url = 'save.php';
            $.ajax(url, {
                type:'POST',
                data: {myData: dataString},
                   success: function(data){
                alert($.trim(data) );
                   },
                   error: function(){
                  alert('Errore');
                   }
            });
            }         
          onSelectPage.call(this, pageNumber, pageSize);

      }   
      else
      {
          onSelectPage.call(this, pageNumber, pageSize);
      }                                 


Title: Re: Stop the events of pagination
Post by: stworthy on January 15, 2020, 07:21:25 PM
Please try to return false in the 'onBeforeSelectPage' event to stop paging. Be sure to download the newest version from the site.
Code:
pager.pagination({
onBeforeSelectPage(pageNumber,pageSize){
if (...){
return false;
}
}
})


Title: Re: Stop the events of pagination
Post by: lomonmic on January 16, 2020, 03:31:11 AM
Thank you for your suggestion.
I downloaded version 1.9.3, but the onBeforeSelectPage event handler seems not to be handled.
Below the code that I tested that does not display the alert.

....
....
var pager = dd.datagrid('getPager');
var popts = pager.pagination('options');
var onBeforeSelectPage = popts.onBeforeSelectPage;

popts.onBeforeSelectPage = function(pageNumber, pageSize){
      alert('ok');
      return false;
}


Title: Re: Stop the events of pagination
Post by: stworthy on January 16, 2020, 07:30:17 PM
Please look at this example https://www.jeasyui.com/demo/test/test9.html. It works fine.


Title: Re: Stop the events of pagination
Post by: lomonmic on January 17, 2020, 12:35:50 AM
Good morning,
I tried the example and I understand why I can't solve with my code. The example works in Firefox, IExplorer, but in Chrome it doesn't display the alert.


Title: Re: Stop the events of pagination
Post by: stworthy on January 17, 2020, 06:48:00 PM
It works fine in Chrome. Please try to refresh your page and make sure the newest 'jquery.easyui.min.js' file is loaded successfully.