EasyUI Forum

General Category => Bug Report => Topic started by: Juan Antonio Martínez on July 12, 2015, 09:25:34 AM



Title: Infinite loop using scrollview in subgrid when empty data is returned
Post by: Juan Antonio Martínez 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


Title: Re: Infinite loop using scrollview in subgrid when empty data is returned
Post by: jarry 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


Title: Re: Infinite loop using scrollview in subgrid when empty data is returned
Post by: Juan Antonio Martínez 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


Title: Re: Infinite loop using scrollview in subgrid when empty data is returned
Post by: jarry 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;
    }
    // ...
}


Title: Re: Infinite loop using scrollview in subgrid when empty data is returned
Post by: Juan Antonio Martínez on July 13, 2015, 02:13:40 AM
OK. Now everything works fine. Thanks

Juan Antonio