EasyUI Forum
April 30, 2024, 01:10:27 AM *
Welcome, Guest. Please login or register.

Login with username, password and session length
News:
 
   Home   Help Search Login Register  
Pages: [1]
  Print  
Author Topic: Stop the events of pagination  (Read 5400 times)
lomonmic
Newbie
*
Posts: 12


View Profile
« 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.
Logged
stworthy
Administrator
Hero Member
*****
Posts: 3581


View Profile Email
« Reply #1 on: January 15, 2020, 01:50:58 AM »

Please show some code snippets and describe your question in more detail.
Logged
lomonmic
Newbie
*
Posts: 12


View Profile
« Reply #2 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);
      }                                 
Logged
stworthy
Administrator
Hero Member
*****
Posts: 3581


View Profile Email
« Reply #3 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;
}
}
})
Logged
lomonmic
Newbie
*
Posts: 12


View Profile
« Reply #4 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;
}
Logged
stworthy
Administrator
Hero Member
*****
Posts: 3581


View Profile Email
« Reply #5 on: January 16, 2020, 07:30:17 PM »

Please look at this example https://www.jeasyui.com/demo/test/test9.html. It works fine.
Logged
lomonmic
Newbie
*
Posts: 12


View Profile
« Reply #6 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.
Logged
stworthy
Administrator
Hero Member
*****
Posts: 3581


View Profile Email
« Reply #7 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.
Logged
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines Valid XHTML 1.0! Valid CSS!