====The problem
hi, I am trying the smartgwtee 2.4 with gwt 2.1.1,
and the problem exist when I use smartgwtee 2.2 and gwt2.0.x.
I use TileGrid to load about 20k+ images from a Hibernate
DataSource, and it works fine at the first load, only fetch
the first 75 records from remote server.
The content of my TileGrid will changed by other user, so
I want to refresh the TileGrid by calling invalidateCache,
then the TileGrid try to load all data after I call fetchData
again.
==The showcase
I reuse the showcase to demonstrate the problem.
First of all, I create the datas in animals table:
Code:
for /L %x in (1,1,10000) do echo INSERT INTO animals
(PICTURE,INFORMATION,COMMONNAME,LIFESPAN,SCIENTIFICNAME,DIET,STATUS) VALUES
('Alligator.jpg','In the 16th century, Spanish explorers in what is now Florida
encountered a large formidable animal which they called "el largo" meaning "the
lizard". The name "el largo" gradually became pronounced
"alligator".','Alligator (American)',50,'%x','Carnivore','Not Endangered'); >>
sql
then execute the sql on the showcase's hsql database, it has 10027 rows now.
Then, change the code, RecategorizeTile.java, comment the row:
// leftGrid.setShowAllRecords(true)
save the file, start the showcase server by "ant hosted"
access the url by ie8:
http://127.0.0.1:8888/index.html?gwt.codesvr=127.0.0.1:9997#recategorize _tile
just click the left selectitem, change it from "Endangered" to
"Not Endangered", then you will see it try to fetch all data from
the database.
==The fix:
I wonder why the refresh will try to reload all the records.
So I enable ie8's script debug, set the breakpoint at the getRange method.
When I see the call stack, I found the getRange's called from getTileRecord,
which defined at line 3278 in ISC_Grid.js, I beautified it as:
Code:
,isc.A.getTileRecord=function isc_TileGrid_getTileRecord(_1){
var _2=this;var _3=_2.data;var _4,_5;
if(isc.isA.ResultSet(this.data)&&!this.data.lengthIsKnown())
return null;
if(this.showAllRecords
|| !_2.getDrawnStartIndex()
||!_2.getDrawnEndIndex())
{
_4=0;_5=_3.getLength()
} else {
_4=_2.getDrawnStartIndex();
_5=_2.getDrawnEndIndex()+1;
if(_5>_3.getLength())_5=_3.getLength()
}
...
When the first time the TileGrid is loaded, the
this.data.lengthIsKnown() return false, so it just return
without the other code called.
When I try to refresh the TileGrid, the this.data.lengthIsKnown() is true,
and the _2.getDrawnStartIndex() is 0, so !_2.getDrawnStartIndex() is true,
it will set _4=0,and _5=_3.getLength(), which means load all the data.
So I change the
!_2.getDrawnStartIndex()
to
_2.getDrawnStartIndex() === undefined
and solve the problem, it will only fetch the first 75 records now. :D
Original issue reported on code.google.com by simon...@gmail.com on 22 Jan 2011 at 2:23
Original issue reported on code.google.com by
simon...@gmail.com
on 22 Jan 2011 at 2:23