EasyUI Forum
May 09, 2024, 12:53:24 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: Infinite loop using scrollview in subgrid when empty data is returned  (Read 9473 times)
Juan Antonio Martínez
Jr. Member
**
Posts: 68



View Profile
« on: July 12, 2015, 09:25:34 AM »

Hi, all:
Using scrollview in datagrid subgrid, I get some extrange results
- first call to load() does not provide 'page' and 'rows' parameters to server
- When empty data is returned ( {"total":0,"rows":[]} ) request is sent again, but now 'page' and 'rows' are properly sent
... and received again an emtpy response so entering in an infinite loop

Using easyui-1.4.2 and latest scrollview.js from web
you can see sample code at:
https://github.com/jonsito/AgilityContest/blob/tablet_optimization/agility/tablet/tablet_competicion.php

When using scrollview in main datagrid (i.e not in a subgrid) everything works fine

Think this is related to this (old) question:
http://www.jeasyui.com/forum/index.php?topic=2300.msg5158#msg5158

Any ideas?
Thanks in advance

Juan Antonio
Logged
jarry
Administrator
Hero Member
*****
Posts: 2262


View Profile Email
« Reply #1 on: July 12, 2015, 07:05:00 PM »

Please try to download the newest 'datagrid-scrollview.js' file from http://www.jeasyui.com/extension/datagridview.php
Logged
Juan Antonio Martínez
Jr. Member
**
Posts: 68



View Profile
« Reply #2 on: July 13, 2015, 12:26:26 AM »

(Thanks for your quick response)

Sorry: no luck.
- First issue (lack of page & rows parameters on first request) now is solved
- But second one ( infinite request loop when response is "empty" {"total":0,"rows":[]} ) still persists

Again: when using scrollview in main datagrid everything works. Failure is only shown when using scrollview in subgrids

EDIT:
This one-liner patch solves second issue; but no idea about collateral effects
Code:
easyui-1.4.2/extensions/datagrid-view/datagrid-scrollview.js 
--- datagrid-scrollview.js 2015-07-13 03:56:21.000000000 +0200
+++ AgilityContest/agility/lib/jquery-easyui-1.4.2/extensions/datagrid-view/datagrid-scrollview.js2015-07-13 09:35:13.773157146 +0200
@@ -374,7 +374,7 @@
  if (data.rows && data.rows.length){
  callback.call(opts.view, data.rows);
  } else {
- opts.onLoadSuccess.call(target, data);
+ if (data.total!=0) opts.onLoadSuccess.call(target, data);
  }
  }, function(){
  $(target).datagrid('loaded');


Juan Antonio
« Last Edit: July 13, 2015, 12:39:11 AM by Juan Antonio Martínez » Logged
jarry
Administrator
Hero Member
*****
Posts: 2262


View Profile Email
« Reply #3 on: July 13, 2015, 01:07:22 AM »

The reason of infinite loop is that 'onLoadSuccess' event handler calls the 'fixDetailRowHeight' method. This method triggers the 'scroll' event, which will make a new request to the server. To solve this issue, just add the code below to the 'onLoadSuccess' code.
Code:
onLoadSuccess:function(data){
    if (!data.total){
        return;
    }
    // ...
}
Logged
Juan Antonio Martínez
Jr. Member
**
Posts: 68



View Profile
« Reply #4 on: July 13, 2015, 02:13:40 AM »

OK. Now everything works fine. Thanks

Juan Antonio
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!