HMG-specific GRID syntax help needed

General Help regarding HMG, Compilation, Linking, Samples

Moderator: Rathinagiri

Red2
Posts: 271
Joined: Sat May 18, 2019 2:11 pm
DBs Used: Visual FoxPro, FoxPro
Location: United States of America

HMG-specific GRID syntax help needed

Post by Red2 »

On a form I have a grid (added using the IDE) to display a table (.DBF). However, when the form is run the grid displays no records.

The table, "All_Items", has 8 type character fields. Its records contain data.
When the form is run the grid's header displays fine but none of the records.
According to the debugger this table is in the current work area and is on recno() 1.

Below are some (likely) relevant lines taken from the .FMG. (For brevity below I have left out "default" lines that may not be the problem).

Code: Select all

DEFINE GRID grd_Items
	...
	ITEMS {"MFG_NAME", "TYPE", "SERVICEABL", "DESCR", "MODEL", "LENGTH", "OAL", "SERIAL_NBR"}
	WIDTHS {100, 100, 100, 100, 100, 100, 100, 100}
	HEADERS {"Mfg. Name", "Type", "Serviceable", "Descr.", "Model", "Length", "OAL", "Serial Nbr"}
	...
	COLUMNCONTROLS {{"TextBox","Character"},{"TextBox","Character"},{"TextBox","Character"},{"TextBox","Character"} ;
			,{"TextBox","Character"},{"TextBox","Character"},{"TextBox","Character"},{"TextBox","Character"}}
	...
	ITEMCOUNT	8
	ROWSOURCE	"All_Items"
	COLUMNFIELDS  {"MFG_NAME", "TYPE", "SERVICEABL", "DESCR", "MODEL", "LENGTH", "OAL", "SERIAL_NBR"}
	...
END GRID
I do not understand my error(s). Can someone point out my HMG/Harbour syntax errors or omissions? Any help would be very greatly appreciated!

Kind Regards,
Red2
martingz
Posts: 394
Joined: Wed Nov 18, 2009 11:14 pm
Location: Mexico

Re: HMG-specific GRID syntax help needed

Post by martingz »

Red2 this works for me

DEFINE GRID Grid_1
ROW 50
COL 10
WIDTH 390
HEIGHT 370
ITEMS { {""} }
VALUE Nil
WIDTHS {400 }
HEADERS {'Descripción'}
FONTNAME "Arial"
FONTSIZE 9
TOOLTIP ""
ONCHANGE Nil
ONGOTFOCUS Nil
ONLOSTFOCUS Nil
FONTBOLD .T.
FONTITALIC .F.
FONTUNDERLINE .F.
FONTSTRIKEOUT .F.
ONDBLCLICK Nil
ONHEADCLICK Nil
ONQUERYDATA Nil
MULTISELECT .F.
ALLOWEDIT .F.
VIRTUAL .F.
DYNAMICBACKCOLOR {tColor}
DYNAMICFORECOLOR Nil
COLUMNWHEN Nil
COLUMNVALID Nil
COLUMNCONTROLS Nil
SHOWHEADERS .T.
CELLNAVIGATION .F.
NOLINES .F.
HELPID Nil
IMAGE Nil
JUSTIFY Nil
ITEMCOUNT Nil
BACKCOLOR NIL
FONTCOLOR NIL
HEADERIMAGES Nil
ROWSOURCE "articulo"
COLUMNFIELDS {'articulo->descrip'}
ALLOWAPPEND .F.
ALLOWDELETE .F.
BUFFERED .F.
DYNAMICDISPLAY Nil
ONSAVE Nil
LOCKCOLUMNS 0
END GRID
User avatar
AUGE_OHR
Posts: 2060
Joined: Sun Aug 25, 2019 3:12 pm
DBs Used: DBF, PostgreSQL, MySQL, SQLite
Location: Hamburg, Germany

Re: HMG-specific GRID syntax help needed

Post by AUGE_OHR »

hi,
Red2 wrote: Wed Dec 04, 2019 9:20 pm

Code: Select all

   ITEMCOUNT	8
   ROWSOURCE	"All_Items"
   COLUMNFIELDS  {"MFG_NAME", "TYPE", "SERVICEABL", "DESCR", "MODEL", "LENGTH", "OAL", "SERIAL_NBR"}
	...
END GRID
try

Code: Select all

   ITEMCOUNT	NIL
   ROWSOURCE	"ALL_ITEMS"
   COLUMNFIELDS  {"ALL_ITEMS->MFG_NAME", "ALL_ITEMS->TYPE", "ALL_ITEMS->SERVICEABL", "ALL_ITEMS->DESCR", "ALL_ITEMS->MODEL", "ALL_ITEMS->LENGTH", "ALL_ITEMS->OAL", "ALL_ITEMS->SERIAL_NBR"}
ITEMCOUNT is IMHO for Array so it is NIL
ROWSOURCE not sure but i think ALIAS() is UPPER() ?
COLUMNFIELDS not need ALIAS but i like to use it.

have fun
have fun
Jimmy
Red2
Posts: 271
Joined: Sat May 18, 2019 2:11 pm
DBs Used: Visual FoxPro, FoxPro
Location: United States of America

Re: HMG-specific GRID syntax help needed

Post by Red2 »

Hi Martingz and AUGE_OHR,

Thank you very much for your gracious assistance. I really appreciate it.

I am still in great need of your HMG/Harbour specific experience. (Sadly, my VFP-specific experience has not given the solution.)
I have carefully tried your suggestions but the data still does not appear in the grid.

Some more information:
As stated in my post the header displays but no data. I can navigate up and down the blank grid the same number of rows as the RECCOUNT().
This demonstrates that the .DBF has loaded but is not displayed in the grid.

I made the following substution in C\HMG.3.4.4\SAMPLES\Basics\TUTORIAL\Tutor20.PRG.
Originally:
// @ 10,10 GRID Grid_1 ;
// WIDTH 610 ;
// HEIGHT 390 ;
// HEADERS { 'Code' , 'First Name' , 'Last Name', 'Birth Date', 'Married' , 'Biography' } ;
// WIDTHS { 150 , 150 , 150 , 150 , 150 , 150 } ;
// ROWSOURCE "Test" ;
// COLUMNFIELDS { 'Code' , 'First' , 'Last' , 'Birth' , 'Married' , 'Bio' } ;
// COLUMNCONTROLS {{'TEXTBOX','NUMERIC','999'},{'TEXTBOX','CHARACTER'},{'TEXTBOX','CHARACTER'},{'TEXTBOX','DATE'},
{'CHECKBOX'},{'TEXTBOX','CHARACTER'}}
;
// ALLOWDELETE ;
// EDIT


With my substutions:

Code: Select all

   @ 10,10 GRID Grid_1 ;
       WIDTH  610 ;
       HEIGHT 390 ; 
      HEADERS {"Mfg. Name", "Type", "Serviceable", "Descr.", "Model", "Length", "OAL", "Serial Nbr"}
       WIDTHS { 150, 150, 150, 150, 150, 150, 150, 150 } ;
       ROWSOURCE "All_Items" ;
       COLUMNFIELDS  {"MFG_NAME", "TYPE", "SERVICEABL", "DESCR", "MODEL", "LENGTH", "OAL", "SERIAL_NBR"}
       COLUMNCONTROLS {{"TextBox","Character"}, {"TextBox","Character"}, {"TextBox","Character"}, {"TextBox","Character"} ;
                     , {"TextBox","Character"}, {"TextBox","Character"}, {"TextBox","Character"}, {"TextBox","Character"}};
       ALLOWDELETE ;
       EDIT
When I run with my substitutions in "Tutor20.PRG" the grid displays all my table's data displays perfectly.
This demonstrates that the table is valid and understood by HMG.


The following is the exact code in my .FMG. I use the same values here as above.
Unfortunately, none of the table's data displays here.
QUESTION: Why above but not in the (IDE created) grid on my form???

Code: Select all

DEFINE GRID grd_Items
    ROW       60
    COL       30
    WIDTH     760
    HEIGHT    150
    ITEMS     { {""} }
    VALUE     Nil
    WIDTHS    {150, 150, 150, 150, 150, 150, 150, 150}
    HEADERS   {"Mfg. Name", "Type", "Serviceable", "Descr.", "Model", "Length", "OAL", "Serial Nbr"}
    FONTNAME       "Arial"
    FONTSIZE       9
    TOOLTIP        ""
    ONCHANGE       Nil
    ONGOTFOCUS     Nil
    ONLOSTFOCUS    Nil
    FONTBOLD      .F.
    FONTITALIC    .F.
    FONTUNDERLINE .F.
    FONTSTRIKEOUT .F.
    ONDBLCLICK     Nil
    ONHEADCLICK    Nil
    ONQUERYDATA    Nil
    MULTISELECT    .F.
    ALLOWEDIT      .F.
    VIRTUAL        .F.
    DYNAMICBACKCOLOR Nil
    DYNAMICFORECOLOR Nil
    COLUMNWHEN       Nil
    COLUMNVALID      Nil
    COLUMNCONTROLS {{"TextBox","Character"},{"TextBox","Character"},{"TextBox","Character"},{"TextBox","Character"} ;
                  , {"TextBox","Character"},{"TextBox","Character"},{"TextBox","Character"},{"TextBox","Character"}}
    SHOWHEADERS    .T.
    CELLNAVIGATION .F.
    NOLINES        .F.
    HELPID         Nil
    IMAGE          Nil
    JUSTIFY        Nil
    ITEMCOUNT      Nil
    BACKCOLOR      NIL
    FONTCOLOR      NIL
    HEADERIMAGES   Nil
    ROWSOURCE      "NFA_ITEMS"
    COLUMNFIELDS  {"MFG_NAME", "TYPE", "SERVICEABL", "DESCR", "MODEL", "LENGTH", "OAL", "SERIAL_NBR"} 
    ALLOWAPPEND    .F.
    ALLOWDELETE    .F.
    BUFFERED       .F.
    DYNAMICDISPLAY  Nil
    ONSAVE          Nil
    LOCKCOLUMNS     0
END GRID
Thank you all for your kind help!
Red2
User avatar
AUGE_OHR
Posts: 2060
Joined: Sun Aug 25, 2019 3:12 pm
DBs Used: DBF, PostgreSQL, MySQL, SQLite
Location: Hamburg, Germany

Re: HMG-specific GRID syntax help needed

Post by AUGE_OHR »

Red2 wrote: Thu Dec 05, 2019 5:37 pm The following is the exact code in my .FMG. I use the same values here as above.
Unfortunately, none of the table's data displays here.
QUESTION: Why above but not in the (IDE created) grid on my form???

Code: Select all

DEFINE GRID grd_Items
    ROW       60
    COL       30
    WIDTH     760
    HEIGHT    150
    ITEMS     { {""} }
hm ... your 1st Msg had

Code: Select all

ITEMS {"MFG_NAME", "TYPE", "SERVICEABL", "DESCR", "MODEL", "LENGTH", "OAL", "SERIAL_NBR"}	
so try

Code: Select all

ITEMS { {"MFG_NAME", "TYPE", "SERVICEABL", "DESCR", "MODEL", "LENGTH", "OAL", "SERIAL_NBR"} }
have fun
Jimmy
ROBROS
Posts: 256
Joined: Thu May 25, 2017 6:30 pm
DBs Used: DBF
Location: D 83071 Stephanskirchen

Re: HMG-specific GRID syntax help needed

Post by ROBROS »

Hi Red,
just a suggestion:
After "use table.dbf" do a "Go Top".
Robert


PS:
Selecting HMG Reference from IDE shows for nvalue of GRID:

GRID (Standard): Numeric (Row Selected).

GRID (Multiselect): Numeric Array (Rows Selected).

GRID (CellNavigation): Numeric Array (Row and col selected).
So you could try value 1,1
User avatar
mol
Posts: 3718
Joined: Thu Sep 11, 2008 5:31 am
Location: Myszków, Poland
Contact:

Re: HMG-specific GRID syntax help needed

Post by mol »

You should set Items to NIL for grid displaying .dbf
Red2
Posts: 271
Joined: Sat May 18, 2019 2:11 pm
DBs Used: Visual FoxPro, FoxPro
Location: United States of America

Re: HMG-specific GRID syntax help needed

Post by Red2 »

Hi Mol,

Thank you very much for your generous help. I tried setting the value of "Items" to Nil but no change. That is, when it runs I can navigate around the grid but no data shows. The cells are all blank.

My Visual FoxPro background tells me that this cannot be that difficult, I am simply making some combination of mistakes, errors, or omissions. I have now spent many hours on this including deleting and re-building the grid.

I will resume again in a day or two. Thank you all for your kind help! I am sure a solution exists.

Thanks again,
Red2
franco
Posts: 816
Joined: Sat Nov 02, 2013 5:42 am
DBs Used: DBF
Location: Canada

Re: HMG-specific GRID syntax help needed

Post by franco »

Hi Red
I suggest putting a * in front of every line of second grid that is not in working grid. Or take the line out because of colins at previous line.
If you use rowsource you do not need items. Also set Value to 1 and take out lockcolumns to start.
I notice rowsource is different in second grid.
I do not usually put lines in a grid or browse that I do not use, they become confusing.
Try to put in line yous need to use that are different from the grid standard.
Hope this helps,
Franco
All The Best,
Franco
Canada
User avatar
AUGE_OHR
Posts: 2060
Joined: Sun Aug 25, 2019 3:12 pm
DBs Used: DBF, PostgreSQL, MySQL, SQLite
Location: Hamburg, Germany

Re: HMG-specific GRID syntax help needed

Post by AUGE_OHR »

hi,

have a look into HMG DOC file for

Code: Select all

allowdelete -> Sample
- "Fields" property :

{'Test->Code','Test->First','Test->Last','Test->Birth','Test->Married','Test->Bio'}

- "Headers" property :

{ 'Code', 'First Name', 'Last Name', 'Birth Date', 'Married', 'Biography' }

- "Widths" property :

{ 150, 150, 150, 150, 150, 150 }

- "Work Area" property :

Test
so it is

Code: Select all

   COLUMNFIELDS {"REPLYTO->REPLYTO" , "REPLYTO->FROM"}
   HEADERS {"Reply To","From"}
   WIDTHS { 200,200 }        
   ROWSOURCE "REPLYTO"
what you need to show a DBF in a FMG

p.s. you have to open DBF before ACTIVATE WINDOW
have fun
Jimmy
Post Reply