HMG-specific GRID syntax help needed

General Help regarding HMG, Compilation, Linking, Samples

Moderator: Rathinagiri

Post Reply
Red2
Posts: 49
Joined: Sat May 18, 2019 2:11 pm
DBs Used: DBF, FoxPro, Visual FoxPro
Location: United States (East Coast)
Has thanked: 13 times
Been thanked: 2 times

HMG-specific GRID syntax help needed

Post by Red2 » Wed Dec 04, 2019 9:20 pm

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: 280
Joined: Wed Nov 18, 2009 11:14 pm
Location: Mexico
Has thanked: 21 times
Been thanked: 15 times

Post by martingz » Thu Dec 05, 2019 2:35 am

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: 290
Joined: Sun Aug 25, 2019 3:12 pm
DBs Used: DBF, PostgreSQL, MySQL, SQLite
Location: Hamburg, Germany
Has thanked: 32 times
Been thanked: 39 times

Post by AUGE_OHR » Thu Dec 05, 2019 3:30 am

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

Red2
Posts: 49
Joined: Sat May 18, 2019 2:11 pm
DBs Used: DBF, FoxPro, Visual FoxPro
Location: United States (East Coast)
Has thanked: 13 times
Been thanked: 2 times

Post by Red2 » Thu Dec 05, 2019 5:37 pm

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: 290
Joined: Sun Aug 25, 2019 3:12 pm
DBs Used: DBF, PostgreSQL, MySQL, SQLite
Location: Hamburg, Germany
Has thanked: 32 times
Been thanked: 39 times

Post by AUGE_OHR » Thu Dec 05, 2019 8:42 pm

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"} }

ROBROS
Posts: 189
Joined: Thu May 25, 2017 6:30 pm
DBs Used: DBF
Location: D 83071 Stephanskirchen
Has thanked: 56 times
Been thanked: 18 times

Post by ROBROS » Fri Dec 06, 2019 2:15 pm

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: 3252
Joined: Thu Sep 11, 2008 5:31 am
Location: Myszków, Poland
Has thanked: 235 times
Been thanked: 132 times
Contact:

Post by mol » Fri Dec 06, 2019 3:37 pm

You should set Items to NIL for grid displaying .dbf

Red2
Posts: 49
Joined: Sat May 18, 2019 2:11 pm
DBs Used: DBF, FoxPro, Visual FoxPro
Location: United States (East Coast)
Has thanked: 13 times
Been thanked: 2 times

Post by Red2 » Sun Dec 08, 2019 10:17 pm

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

Post Reply