Page 1 of 2

Bug in virtual grid / strange behaviour

Posted: Sat Mar 01, 2014 3:08 pm
by jpp
hi to all

whith a standard virtual grid, the querydata is called only to display datas on the "visible grid".
if you add Dynamicbackcolor the querrydata is called for all the itemcount.

so the virtual grid becomes unusable ...

please test my simple sample !
Hope the kings of HMg will give me a workaround !
thanks a lot

#include "hmg.ch"

Function Main
local bcolor := { || if ( This.CellRowIndex/2 == int(This.CellRowIndex/2) , ;
{ 223,253,255 } , { 255,255,255 } ) }
private count:=0

DEFINE WINDOW Form_1 ;
AT 0,0 ;
WIDTH 450 ;
HEIGHT 400 ;
TITLE 'Hello World!' ;
MAIN

DEFINE MAIN MENU
DEFINE POPUP 'File'
MENUITEM 'Change ItemCount' ACTION Form_1.Grid_1.ItemCount := Val(InputBox('New Value','Change ItemCount'))
MENUITEM 'go 20000' ACTION Form_1.Grid_1.value := 20000
MENUITEM "Count" ACTION msgbox(str(count,8,0))
END POPUP
END MENU

@ 10,10 GRID Grid_1 ;
WIDTH 400 ;
HEIGHT 330 ;
HEADERS {'Column 1'} ;
WIDTHS {140};
VIRTUAL ;
ITEMCOUNT 1000000 ;
ON QUERYDATA QueryTest();
DYNAMICBACKCOLOR { BCOLOR }

END WINDOW

CENTER WINDOW Form_1

ACTIVATE WINDOW Form_1

Return

Procedure QueryTest()
count++
This.QueryData := Str ( This.QueryRowIndex ) + ',' + Str ( This.QueryColIndex )
Return

Re: Bug in virtual grid / strange behaviour

Posted: Sat Mar 01, 2014 3:18 pm
by mol
I confirm.

Re: Bug in virtual grid / strange behaviour

Posted: Sat Mar 01, 2014 3:46 pm
by esgici
Sorry jpp and mol :(

I didn't understand the problem,

the "bug" and "unusable" are meaningless for me :(

May be this is my stupidy, but without understand the problem it's impossible to help :!:

And jpp,

please put your code between "code" and "/code" tags ( you can use "Code" button in the menu bar of post-edit window);
and more importantly please make proper indentation for easy to read and understanding.

I applied these to your code as an example :

Code: Select all

#include "hmg.ch"

Function Main
   local bcolor := { || if ( This.CellRowIndex/2 == int(This.CellRowIndex/2) , ;
                            { 223,253,255 } , { 255,255,255 } ) }
   private count:=0

   DEFINE WINDOW Form_1 ;
      AT 0,0 ;
      WIDTH 450 ;
      HEIGHT 400 ;
      TITLE 'Hello World!' ;
      MAIN 

      DEFINE MAIN MENU
         DEFINE POPUP 'File'
            MENUITEM 'Change ItemCount' ACTION Form_1.Grid_1.ItemCount := Val(InputBox('New Value','Change ItemCount'))
            MENUITEM 'go 20000' ACTION Form_1.Grid_1.value := 20000
            MENUITEM "Count" ACTION msgbox(str(count,8,0))
         END POPUP
      END MENU

      @ 10,10 GRID Grid_1 ;
            WIDTH 400 ;
            HEIGHT 330 ;
            HEADERS {'Column 1'} ;
            WIDTHS {140};
            VIRTUAL ;
            ITEMCOUNT 1000000 ;
            ON QUERYDATA QueryTest();
            DYNAMICBACKCOLOR { BCOLOR }

   END WINDOW

   CENTER WINDOW Form_1

   ACTIVATE WINDOW Form_1

Return

Procedure QueryTest()
   count++
   This.QueryData := Str ( This.QueryRowIndex ) + ',' + Str ( This.QueryColIndex )
Return
Happy HMG'ing ( without 'bug' and 'unusable' problems ) :D

Re: Bug in virtual grid / strange behaviour

Posted: Sat Mar 01, 2014 4:15 pm
by jpp
hi esgici,

sorry for the code, i will do in the correct way next time.

the problem is that the virtual grid is done to "load" the part of data needed for the display.
that is done without dynamicbackcolor.

if you have tried my sample, you can compute the time to load the grid and the refresh time.

make the test with 100 columns, you time to drink ure coffee.

That's why i say that is quite unusable.

Do you know is there is a way to know if the grid is in idle state ( refresh and redraw done ), that is as the old clipper function forcestable() or stabilize() ?

Another strange behaviour : if you move the mouse over the grid, the query data is called as long as the mouse move...

thanks !

Re: Bug in virtual grid / strange behaviour

Posted: Sat Mar 01, 2014 4:54 pm
by esgici
jpp wrote:hi esgici,
...
the problem is that the virtual grid is done to "load" the part of data needed for the display.
that is done without dynamicbackcolor.
...
Did you search dynamicbackcolor in posts and inspect questions and answers ?

Especially is your HMG version correct ( last and Unicode ) ?

Because I didn't any problem on dynamicbackcolor ,

Happy HMG'ing :D

Re: Bug in virtual grid / strange behaviour

Posted: Sat Mar 01, 2014 6:40 pm
by jpp
esgici,

i have the last HMG 3.2.

i have read all what could.

i've spent 8h on this problem

if u tries my code ( with and without dynamicbackcolor ) u will see the difference.

as you know well HMG, in h_grid.prg in the proc _HMG_DOGRIDREFRESH you can see :

IF lProcess_Dynamic_Back_Color == .T.
aTemp := ARRAY ( MaxGridRows , MaxGridCols ) <- mawgridcols = itemcount ( if your itemcount is 10 000 000 ) it's create a such array which is not the purpose of a virtual grid...

in a general way, i studie and tries lot of things before i post something.

but my pb as now still no workaround.

Re: Bug in virtual grid / strange behaviour

Posted: Sun Mar 02, 2014 3:20 am
by Javier Tovar
Jpp I compile your example and not encounter any discomfort, if indeed increases with time DinamicBackColor 1,000,000 items, but do not consider it a long time, if it increases 5 times the load time, but I consider normal as eg once did a similar small town in Excel and fail to 1,000,000 rows and increasing formats and formulas, if that was really slow! It's just a comparison. and a database of 100 fields have not seen one!

regards

Re: Bug in virtual grid / strange behaviour

Posted: Sun Mar 02, 2014 9:38 am
by mol
try to add this phrase in QueryTest function:

Code: Select all

if this.queryrowindex = 100000
  MsgBox('100000 row encountered')
endif

Re: Bug in virtual grid / strange behaviour

Posted: Sun Mar 02, 2014 6:00 pm
by Javier Tovar
Hi Mol,
mol wrote:try to add this phrase in QueryTest function:


Code:
if this.queryrowindex = 100000
  MsgBox('100000 row encountered')
endif

Successful or unsuccessful?

I integrate the function and if it works well.

regards

Code: Select all

Procedure QueryTest()
	count++
	This.QueryData := Str ( This.QueryRowIndex ) + ',' + Str ( This.QueryColIndex )
	if this.queryrowindex = 100000
	  MsgBox('100000 row encountered')
	endif
Return
Bien.jpg
Bien.jpg (53.69 KiB) Viewed 4643 times

Re: Bug in virtual grid / strange behaviour

Posted: Sun Mar 02, 2014 6:21 pm
by mol
This message should appear after scrolling to 100000 row. Not at the initiation of the grid. Virtual grid shouldn't touch 100000' row till the time when this row should be presented on the screen.