A grid.cell problem

General Help regarding HMG, Compilation, Linking, Samples

Moderator: Rathinagiri

User avatar
mol
Posts: 3825
Joined: Thu Sep 11, 2008 5:31 am
Location: Myszków, Poland
Contact:

Re: A grid.cell problem

Post by mol »

I'm afraid I couldn't understand this point. What is difference database and table ?
I don't know the difference, maybe it's a bug?
I've tried to analize h_grid.prg but it requires more time to understand all philosophy of HMG.

Regards, Marek
User avatar
mol
Posts: 3825
Joined: Thu Sep 11, 2008 5:31 am
Location: Myszków, Poland
Contact:

Re: A grid.cell problem

Post by mol »

reference:

Code: Select all

cContent := this.Cell( nRow, nCol )
call function

Code: Select all

FUNCTION _HMG_GETGRIDCELLVALUE ( CONTROLNAME , PARENTFORM , ROW , COL )
*------------------------------------------------------------------------------*
LOCAL A
LOCAL V

	A := _GetItem ( CONTROLNAME , PARENTFORM , ROW  )

	V := A [ COL ]

RETURN V
in HMG.

Going this way, function _GetItem is defined in controlmisc.prg and here is a cut of it, which returns value from grid:

Code: Select all

	case T == "GRID" .OR. T == "MULTIGRID"

		IF _HMG_SYSDATA [ 40 ] [ i ] [ 9 ] == .F.

			AEDITCONTROLS := _HMG_SYSDATA [ 40 ] [I] [2]

			IF VALTYPE ( AEDITCONTROLS ) != 'A'

				RetVal := ListViewGetItem ( c , Item , Len ( _HMG_SYSDATA [  7 ] [i] ) ) 

			ELSE

				V := ListViewGetItem ( c , Item , Len( _HMG_SYSDATA [  7 ] [i] ) )

				ATEMP := ARRAY ( Len( _HMG_SYSDATA [  7 ] [i] ) )

				FOR CI := 1 TO Len( _HMG_SYSDATA [  7 ] [i] )

					XRES := _HMG_PARSEGRIDCONTROLS ( AEDITCONTROLS , CI )

					AEC		:= XRES [1]	
					CTYPE		:= XRES [2]	
					CINPUTMASK	:= XRES [3]	
					CFORMAT		:= XRES [4]	
					AITEMS		:= XRES [5]	
					ARANGE		:= XRES [6]	
					DTYPE		:= XRES [7]	
					ALABELS		:= XRES [8]	

					IF AEC == 'TEXTBOX' 
						IF CTYPE == 'NUMERIC'
							IF CFORMAT = 'E'
								ATEMP [CI] := GetNumFromCellTextSp ( v [CI] )
							ELSE
								ATEMP [CI] := GetNumFromCellText ( v [CI] )
							ENDIF
						ELSEIF CTYPE == 'DATE'
							ATEMP [CI] := CTOD ( v [CI] )
						ELSEIF CTYPE == 'CHARACTER'
							ATEMP [CI] := v [CI]		
						ENDIF

					ELSEIF AEC == 'DATEPICKER'
						ATEMP [CI] := CTOD (V [CI] )

					ELSEIF AEC == 'COMBOBOX'
						Z := 0
						FOR X := 1 TO LEN ( AITEMS )
							IF UPPER ( ALLTRIM( V [CI] ) ) == UPPER ( ALLTRIM ( AITEMS [X] ) )
								Z := X
								EXIT
							ENDIF
						NEXT X
						ATEMP [CI] := 	Z

					ELSEIF AEC == 'SPINNER'
							ATEMP [CI] := VAL (V [CI] )
					ELSEIF AEC == 'CHECKBOX'
						IF ALLTRIM(UPPER(V[CI])) == ALLTRIM(UPPER(ALABELS [1]))
							ATEMP [CI] :=  .T.
						ELSEIF ALLTRIM(UPPER(V[CI])) == ALLTRIM(UPPER(ALABELS [2]))
							ATEMP [CI] := .F.
						ENDIF
					ENDIF
	
			        NEXT CI

				RetVal := ATEMP

			ENDIF

			if Len ( _HMG_SYSDATA [ 14 ] [i] ) > 0
				if len (RetVal) >= 1
					RetVal [1] := GetImageListViewItems( c , Item )
				EndIf
			EndIf

		ENDIF

	endcase
_HMG_SYSDATA [ 40 ] [ i ] [ 9 ] is set to .T. if you define ROWSOURCE property
So, the fragment of _GetItem is never done when RowSource property is declared.

I think, its a bug of HMG or not completed function _GetItem which should return field value if _HMG_SYSDATA [ 40 ] [ i ] [ 9 ] (ROWSOURCE) is defined.

Roberto should help us when he will be back.
Marek
User avatar
esgici
Posts: 4543
Joined: Wed Jul 30, 2008 9:17 pm
DBs Used: DBF
Location: iskenderun / Turkiye
Contact:

Re: A grid.cell problem

Post by esgici »

mol wrote: I've modified a little your function. It was necessary to call _HMG_SysData table to retrieve some data.
Thanks a lot Marek, it work fine.

I don't like using HMG internals such as _HMG_SysData :(

My opinion is (whatever system may be, HMG or anything else):

First : If it's appropriate for our usage, it has been open; certainly there are important reasons for being internal.

Second : "internal" means "undocumented" and "undocumented" means "will be change in the future" and the worst point is: since it is "undocumented", most probably we will be unaware about that change. For example IMHO we haven't any warrant like "40 , 10, 11... are fixed values, doesn't change any time" about indexes of _HMG_SysData you are used for getting needed data; :(

All of this negations discourage me.

Although, I got valuable infos from your correction; thanks.

IMHO the best way is waiting Roberto

Thanks again to your trouble :)

Regards

--

Esgici
Viva INTERNATIONAL HMG :D
User avatar
mol
Posts: 3825
Joined: Thu Sep 11, 2008 5:31 am
Location: Myszków, Poland
Contact:

Re: A grid.cell problem

Post by mol »

I agree with you.
But, searching solution of your problem, I found no solution without using INTERNALS.
Sometimes it's necessary to use low level, but you must remember of it.

I think it's only unfinished work of _GetItem. Roberto informed us the GRID control is unfinished yet.

Regards, Marek
Last edited by mol on Fri Jul 30, 2010 12:35 pm, edited 1 time in total.
User avatar
esgici
Posts: 4543
Joined: Wed Jul 30, 2008 9:17 pm
DBs Used: DBF
Location: iskenderun / Turkiye
Contact:

Re: A grid.cell problem

Post by esgici »

Hi Marek

You are right, thanks again.

Regards

--

Esgici
Viva INTERNATIONAL HMG :D
User avatar
cdsaenz
Posts: 58
Joined: Sun Jul 11, 2010 4:02 am

Re: A grid.cell problem

Post by cdsaenz »

mol wrote:I was reading sources of HMG and It looks that internal table of GRID is not initialized when ROWSOURCE is declared. So you can not use phrase:

Code: Select all

cContent := this.Cell( nRow, nCol )
to retrieve data from database driven grid.

I've modified a little your function. It was necessary to call _HMG_SysData table to retrieve some data.

Code: Select all

PROC ShowG2Cell() 
	local i
	local aValue, aColumnFields, cField
	local cContent
	local nRecNo

	if lInitTime
		return
	endif
	
	aValue := This.Value
	nRow := aValue[ 1 ]
	nCol := aValue[ 2 ]
	
	i := GetControlIndex ( This.Name , ThisWindow.Name )
	xSelect := _HMG_SYSDATA [ 40 ] [ i ] [ 10 ] 
	if valtype(xSelect) = "C"
		// database driven grid
		aColumnFields := _HMG_SYSDATA [ 40 ] [ i] [ 11 ]
		nRecNo := GetProperty(ThisWindow.Name, This.Name, "RecNo")
		goto nRecno
		cField := aColumnFields[nCol]
		cContent := &cField
	else
		cContent := this.Cell( nRow, nCol )
    endif
	MsgBox( cContent )   
	
RETU // ShowG2Cell() 
PS. Didn't I write you should asleep with problem? :D

Besides, I think it should be easier way to retrieve data from grid based on database, not table. It's next job for Roberto :)
Best regards, Marek
Amazing handling of HMG internals! Let's hope that the cell value can be published consistently (eg This.CellValue) in the next HMG version.
Charly
Argentina, Hobbyist developer, Clipper/Delphi/PHP/Progress
User avatar
esgici
Posts: 4543
Joined: Wed Jul 30, 2008 9:17 pm
DBs Used: DBF
Location: iskenderun / Turkiye
Contact:

Re: A grid.cell problem

Post by esgici »

esgici wrote: ... this is my principal problem : when changing row of grid, record of table doesn't change always :shock:
This is my SSW sample demonstrating this problem.

( This bring to my mind an old ( and solved ) problem; but I couldn't remember which it was :( )

Regards

--

Esgici
Attachments
GridSync.rar
Synchronism problem in data bound GRID
(1.7 KiB) Downloaded 253 times
Viva INTERNATIONAL HMG :D
User avatar
mol
Posts: 3825
Joined: Thu Sep 11, 2008 5:31 am
Location: Myszków, Poland
Contact:

Re: A grid.cell problem

Post by mol »

SORRY, WEEKEND TIME!
hahaha!
Marek
User avatar
esgici
Posts: 4543
Joined: Wed Jul 30, 2008 9:17 pm
DBs Used: DBF
Location: iskenderun / Turkiye
Contact:

Re: A grid.cell problem

Post by esgici »

Good weekend my friend :)

Regards

--

Esgici
Viva INTERNATIONAL HMG :D
User avatar
mol
Posts: 3825
Joined: Thu Sep 11, 2008 5:31 am
Location: Myszków, Poland
Contact:

Re: A grid.cell problem

Post by mol »

Good weekend my friend :)

Regards

--

Esgici
For you too, Esgici!

It was very hard week. Too much work. I need some rest.
Post Reply