Strange behavior in virtual grid

HMG Unicode versions 3.1.x related

Moderator: Rathinagiri

User avatar
Amarante
Posts: 182
Joined: Fri Apr 27, 2012 9:44 pm
DBs Used: DBF, MySQL, MariaDB, SQLite, PostgreSQL
Location: Araruama-RJ, Brazil

Strange behavior in virtual grid

Post by Amarante »

Please, anyone know the reason for this behavior on the grid?

Code: Select all

****************************************************************************
* TEST VIRTUAL GRID
****************************************************************************
#include "hmg.ch"

FUNCTION Main()

PRIVATE aMyData  := {}
PRIVATE bColor := { || IIF( This.CellRowIndex / 2 == INT( This.CellRowIndex / 2 ) , { 222,222,222 } , { 255,255,255 } ) }

DEFINE WINDOW Win_Grid ;
		AT 0,0 ;
		WIDTH 450 ;
		HEIGHT 400 ;
		TITLE "Test Virtual Grid" ;
		MAIN

  DEFINE GRID My_Grid
    ROW 10
    COL 10
    WIDTH 400
    HEIGHT 330
    HEADERS { "Number", "Date", "String" }
    WIDTHS { 60, 100, 140 }
    DYNAMICBACKCOLOR { bColor , bColor , bColor }
    ITEMS aMyData
    ITEMCOUNT LEN( aMyData )
    *---------------------------------------------------------------------------
    * Parameters for Virtual Grid
    *---------------------------------------------------------------------------
    VIRTUAL .T.
    ONQUERYDATA Grid_Query()
  END GRID

END WINDOW

*---------------------------------------------------------------------------
* Prepare Mounting Grid
*---------------------------------------------------------------------------
Create_Data()

CENTER WINDOW Win_Grid
ACTIVATE WINDOW Win_Grid

Return


****************************************************************************
STATIC FUNCTION Create_Data()
****************************************************************************
LOCAL x
aMyData := {}
FOR x = 1 TO 100
  AADD( aMyData, { x, DATE() - x, "TESTE" } )
NEXT x
*---------------------------------------------------------------------------
* Entering Data on the Grid
*---------------------------------------------------------------------------
DECLARE WINDOW Win_Grid
Win_Grid.My_Grid.DeleteAllItems
IF LEN( aMyData ) > 0
  *---------------------------------------------------------------------------
  * Sets the current position of the item in the grid
  *---------------------------------------------------------------------------
  Win_Grid.My_Grid.ItemCount := LEN( aMyData )
  Win_Grid.My_Grid.Value     := 1
  Win_Grid.My_Grid.Refresh
  Win_Grid.My_Grid.SetFocus
ENDIF

RETURN NIL


****************************************************************************
FUNCTION Grid_Query()
****************************************************************************
LOCAL nRow_   := This.QueryRowIndex
LOCAL nCol_   := This.QueryColIndex
This.QueryData := Convert2Sstring( aMyData[ nRow_, nCol_ ] )

RETURN NIL


****************************************************************************
FUNCTION Convert2Sstring( xData_ )
* converting to string
****************************************************************************
LOCAL xReturn_ := ""

*---------------------------------------------------------------------------
* Character
*---------------------------------------------------------------------------
IF VALTYPE( xData_ ) = "C"
  xReturn_ := xData_
*---------------------------------------------------------------------------
* Numerical
*---------------------------------------------------------------------------
ELSEIF VALTYPE( xData_ ) == "N"
  xReturn_ := LTRIM( STR( xData_ ) )
*---------------------------------------------------------------------------
* Date
*---------------------------------------------------------------------------
ELSEIF VALTYPE( xData_ ) == "D"
  xReturn_ := DTOC( xData_ )
*---------------------------------------------------------------------------
* The data can not be converted
*---------------------------------------------------------------------------
ELSE
  xReturn_ := ""
ENDIF

RETURN xReturn_
See the picture
Attachments
GRID.JPG
GRID.JPG (58.3 KiB) Viewed 10651 times
User avatar
Amarante
Posts: 182
Joined: Fri Apr 27, 2012 9:44 pm
DBs Used: DBF, MySQL, MariaDB, SQLite, PostgreSQL
Location: Araruama-RJ, Brazil

Re: Strange behavior in virtual grid

Post by Amarante »

Here are the files for those who want to test
Attachments
Grid_Demo.rar
(868.21 KiB) Downloaded 621 times
User avatar
andyglezl
Posts: 1461
Joined: Fri Oct 26, 2012 7:58 pm
Location: Guadalajara Jalisco, MX
Contact:

Re: Strange behavior in virtual grid

Post by andyglezl »

Hola Amarante

Que yo sepa, el Grid solo maneja datos tipo "caracter"
(Nota: Estoy hablando del GRID, no del array)

Tendrias que poner:

FOR x = 1 TO 100
AADD( aMyData, { STR(x), DTOC(DATE() - x), "TESTE" } )
NEXT x
----------------------------------------------------------
Hello Amarante

To my knowledge, the Grid only handles data type "character"
(Note: I'm talking about GRID, not array)

You'd have to put:
FOR x = 1 TO 100
AADD( aMyData, { STR(x), DTOC(DATE() - x), "TESTE" } )
NEXT x
Andrés González López
Desde Guadalajara, Jalisco. México.
User avatar
Amarante
Posts: 182
Joined: Fri Apr 27, 2012 9:44 pm
DBs Used: DBF, MySQL, MariaDB, SQLite, PostgreSQL
Location: Araruama-RJ, Brazil

Re: Strange behavior in virtual grid

Post by Amarante »

andyglezl wrote:Hola Amarante

Que yo sepa, el Grid solo maneja datos tipo "caracter"
(Nota: Estoy hablando del GRID, no del array)

Tendrias que poner:

FOR x = 1 TO 100
AADD( aMyData, { STR(x), DTOC(DATE() - x), "TESTE" } )
NEXT x
----------------------------------------------------------
Hello Amarante

To my knowledge, the Grid only handles data type "character"
(Note: I'm talking about GRID, not array)

You'd have to put:
FOR x = 1 TO 100
AADD( aMyData, { STR(x), DTOC(DATE() - x), "TESTE" } )
NEXT x

andyglezl, Thanks for answering.
But when I use queryData I'm sending data strings for the grid, I urge is that I do not understand.
If you change the routine of converting data to string columns appear normal, ie, does not seem to be the reason that you mentioned.
see example changed

Code: Select all

****************************************************************************
FUNCTION Convert2Sstring( xData_ )
* converting to string
****************************************************************************
LOCAL xReturn_ := ""

*---------------------------------------------------------------------------
* Character
*---------------------------------------------------------------------------
IF VALTYPE( xData_ ) = "C"
  xReturn_ := xData_
*---------------------------------------------------------------------------
* Numerical
*---------------------------------------------------------------------------
ELSEIF VALTYPE( xData_ ) == "N"
  xReturn_ := str( xData_, 35 )       //  LTRIM( STR( xData_ ) )
*---------------------------------------------------------------------------
* Date
*---------------------------------------------------------------------------
ELSEIF VALTYPE( xData_ ) == "D"
  xReturn_ := REPLICATE( DTOC( xData_ ) + ", ", 4 )      // DTOC( xData_ )
*---------------------------------------------------------------------------
* The data can not be converted
*---------------------------------------------------------------------------
ELSE
  xReturn_ := ""
ENDIF

RETURN xReturn_
Attachments
GRID2.JPG
GRID2.JPG (98.55 KiB) Viewed 10628 times
User avatar
Amarante
Posts: 182
Joined: Fri Apr 27, 2012 9:44 pm
DBs Used: DBF, MySQL, MariaDB, SQLite, PostgreSQL
Location: Araruama-RJ, Brazil

Re: Strange behavior in virtual grid

Post by Amarante »

The problem is that I can not display a simple CTOD () or str ().
It seems to be related to the size of the column, but I still can not find the reason. :( :roll:
User avatar
srvet_claudio
Posts: 2193
Joined: Thu Feb 25, 2010 8:43 pm
Location: Uruguay
Contact:

Re: Strange behavior in virtual grid

Post by srvet_claudio »

Remove the grid this line

Code: Select all

  DEFINE GRID My_Grid
    ROW 10
    COL 10
    WIDTH 400
    HEIGHT 330
    HEADERS { "Number", "Date", "String" }
    WIDTHS { 60, 100, 140 }
    DYNAMICBACKCOLOR { bColor , bColor , bColor }
    ITEMS aMyData
//    ITEMCOUNT LEN( aMyData )  <-- REMOVE
    *---------------------------------------------------------------------------
    * Parameters for Virtual Grid
    *---------------------------------------------------------------------------
    VIRTUAL .T.
    ONQUERYDATA Grid_Query()
  END GRID
because at this level LEN( aMyData ) = 0
Best regards.
Dr. Claudio Soto
(from Uruguay)
http://srvet.blogspot.com
User avatar
Amarante
Posts: 182
Joined: Fri Apr 27, 2012 9:44 pm
DBs Used: DBF, MySQL, MariaDB, SQLite, PostgreSQL
Location: Araruama-RJ, Brazil

Re: Strange behavior in virtual grid

Post by Amarante »

srvet_claudio wrote:Remove the grid this line

Code: Select all

  DEFINE GRID My_Grid
    ROW 10
    COL 10
    WIDTH 400
    HEIGHT 330
    HEADERS { "Number", "Date", "String" }
    WIDTHS { 60, 100, 140 }
    DYNAMICBACKCOLOR { bColor , bColor , bColor }
    ITEMS aMyData
//    ITEMCOUNT LEN( aMyData )  <-- REMOVE
    *---------------------------------------------------------------------------
    * Parameters for Virtual Grid
    *---------------------------------------------------------------------------
    VIRTUAL .T.
    ONQUERYDATA Grid_Query()
  END GRID
because at this level LEN( aMyData ) = 0
Claudio, I made the suggested change but unfortunately the error remains.
Attachments
grid3.jpg
grid3.jpg (44.24 KiB) Viewed 10623 times
EduardoLuis
Posts: 682
Joined: Tue Jun 04, 2013 6:33 pm
Location: Argentina

Re: Strange behavior in virtual grid

Post by EduardoLuis »

Hola Amarante:

Disculpa, que te pregunte, pero has hecho el upgrade de la versió 3.15 que publicó Claudio ?
Yo he testeado tu grid demo y funciona perfectamente.- Si no lo has hecho, descarga el patch y actualiza tu versión.-
User avatar
srvet_claudio
Posts: 2193
Joined: Thu Feb 25, 2010 8:43 pm
Location: Uruguay
Contact:

Re: Strange behavior in virtual grid

Post by srvet_claudio »

EduardoLuis wrote:Hola Amarante:

Disculpa, que te pregunte, pero has hecho el upgrade de la versió 3.15 que publicó Claudio ?
Yo he testeado tu grid demo y funciona perfectamente.- Si no lo has hecho, descarga el patch y actualiza tu versión.-
+1
Best regards.
Dr. Claudio Soto
(from Uruguay)
http://srvet.blogspot.com
User avatar
Amarante
Posts: 182
Joined: Fri Apr 27, 2012 9:44 pm
DBs Used: DBF, MySQL, MariaDB, SQLite, PostgreSQL
Location: Araruama-RJ, Brazil

Re: Strange behavior in virtual grid

Post by Amarante »

I have installed the versions:
HMG.3.1.5 Demos patch2.rar
HMG 3.1.5 patch2.rar
If there are others please let me know.
Post Reply