HMG 3.4.3

HMG Unicode versions 3.1.x related

Moderator: Rathinagiri

huiyi_ch
Posts: 53
Joined: Sat May 21, 2016 5:27 am
Has thanked: 1 time
Been thanked: 7 times

Re: GRID CONTROL problem

Post by huiyi_ch » Wed Dec 07, 2016 1:47 pm

Hello Dr. Claudio Soto
当我打开数据库(表),与之绑定的GRID 显示正常,但是当我对数据库进行过滤后,我发现符合条件的记录显示不正确.
When I open the database (table), with the binding of the GRID show normal, but when I filter the database, I found that the records are not displayed correctly.
jpeg1.jpg
jpeg1.jpg (56 KiB) Viewed 1124 times
JPEG2.jpg
JPEG2.jpg (57.29 KiB) Viewed 1124 times
I included my sources and database in attachment in a zip-file.
I use WindowsXp, and installed HMG.3.4.3.Setup.exe.

Code: Select all

#include <hmg.ch>
Function Main
    MAKEDATA()
    DEFINE WINDOW MAIN AT 213 , 425;
		WIDTH 482 HEIGHT 350 VIRTUAL WIDTH Nil VIRTUAL HEIGHT Nil ;
		TITLE "Test grid control" ICON NIL MAIN CURSOR NIL
		
    DEFINE LABEL Label_1
        ROW    30
        COL    40
        WIDTH  120
        HEIGHT 24
        VALUE "Enter filter value"
        FONTNAME "Arial"
        FONTSIZE 9
        TOOLTIP ""
        ACTION Nil
        AUTOSIZE .F.
        BACKCOLOR NIL
        FONTCOLOR NIL
        RIGHTALIGN .T. 
    END LABEL

    DEFINE TEXTBOX Text_1
        ROW    30
        COL    180
        WIDTH  120
        HEIGHT 24
        FONTNAME "Arial"
        FONTSIZE 9
        TOOLTIP ""
        CASECONVERT NONE
        BACKCOLOR NIL
        FONTCOLOR NIL
        INPUTMASK "!!!!!"
        FORMAT Nil
        VALUE ""
    END TEXTBOX

    DEFINE BUTTON Button_1
        ROW    30
        COL    330
        WIDTH  100
        HEIGHT 28
        ACTION FILTER(MAIN.TEXT_1.VALUE)
        CAPTION "FILTER"
        FONTNAME "Arial"
        FONTSIZE 9
        TOOLTIP ""
        PICTURE Nil
        PICTALIGNMENT TOP
    END BUTTON

    DEFINE GRID Grid_1
        ROW    80
        COL    30
        WIDTH  420
        HEIGHT 210
        ITEMS { {""} }
        VALUE Nil
        WIDTHS {200,200 }
        HEADERS {"field1","field2"}
        FONTNAME "Arial"
        FONTSIZE 9
        TOOLTIP ""
        
        BACKCOLOR NIL
        FONTCOLOR NIL
        HEADERIMAGES Nil
        ROWSOURCE "test"
        COLUMNFIELDS {"AA","BB"}
        ALLOWAPPEND .F.
        ALLOWDELETE .F.
        BUFFERED .F.
        DYNAMICDISPLAY Nil
        ONSAVE Nil
        LOCKCOLUMNS 0
    END GRID

END WINDOW
        Main.Center
        Main.Activate

Return

function makedata()
  local astru:={{"AA","C",3,0},{"BB","C",5,0}}
  dbcreate("test.dbf",astru)
  use test new
  dbAppend()
  TEST->AA:="11"
  TEST->BB:="AAAAA"
  dbAppend()
  TEST->AA:="12"
  TEST->BB:="BBBBB"
  dbAppend()
  TEST->AA:="13"
  TEST->BB:="AAAAA"
  dbAppend()
  TEST->AA:="14"
  TEST->BB:="CCCCC"
  dbAppend()
  TEST->AA:="15"
  TEST->BB:="AAAAA"
   dbAppend()
  TEST->AA:="16"
  TEST->BB:="AAAAA"
  
  RETURN NIL
  
  FUNCTION FILTER(CVALUE)
  IF EMPTY(CVALUE)
    dbClearFilter()
  ELSE	 
    dbSETFilter({||TEST->BB==CVALUE})
  ENDIF
  TEST->(DBGOTOP())
  MAIN.GRID_1.REFRESH()
  RETURN NIL
  
test.rar
(1.09 KiB) Downloaded 32 times

Best regards, HUIYI

User avatar
srvet_claudio
Posts: 1911
Joined: Thu Feb 25, 2010 8:43 pm
Location: Uruguay
Has thanked: 25 times
Been thanked: 92 times
Contact:

Post by srvet_claudio » Wed Dec 07, 2016 3:09 pm

Thanks for report
Best regards.
Dr. Claudio Soto
(from Uruguay)
http://srvet.blogspot.com

User avatar
serge_girard
Posts: 1698
Joined: Sun Nov 25, 2012 2:44 pm
DBs Used: 1 MySQL - MariaDB
2 DBF
Location: Belgium
Has thanked: 204 times
Been thanked: 31 times
Contact:

Post by serge_girard » Wed Dec 07, 2016 4:41 pm

Huiyi,

I use this, working, construction :

Code: Select all

    SET FILTER TO ALLTRIM(CVALUE) $ ALLTRIM(TEST->BB) 
Hope this helps!

Serge

huiyi_ch
Posts: 53
Joined: Sat May 21, 2016 5:27 am
Has thanked: 1 time
Been thanked: 7 times

Post by huiyi_ch » Thu Dec 08, 2016 1:21 am

serge_girard wrote:Huiyi,

I use this, working, construction :

Code: Select all

    SET FILTER TO ALLTRIM(CVALUE) $ ALLTRIM(TEST->BB) 
Hope this helps!

Serge
I replaced my code with yours, I recompiled the program, and now the GRID still is incorrect!

User avatar
srvet_claudio
Posts: 1911
Joined: Thu Feb 25, 2010 8:43 pm
Location: Uruguay
Has thanked: 25 times
Been thanked: 92 times
Contact:

Post by srvet_claudio » Thu Dec 08, 2016 2:07 am

serge_girard wrote:Huiyi,

I use this, working, construction :

Code: Select all

    SET FILTER TO ALLTRIM(CVALUE) $ ALLTRIM(TEST->BB) 
Hope this helps!

Serge
Thanks Serge for solver this problem !
Best regards.
Dr. Claudio Soto
(from Uruguay)
http://srvet.blogspot.com

User avatar
serge_girard
Posts: 1698
Joined: Sun Nov 25, 2012 2:44 pm
DBs Used: 1 MySQL - MariaDB
2 DBF
Location: Belgium
Has thanked: 204 times
Been thanked: 31 times
Contact:

Post by serge_girard » Thu Dec 08, 2016 8:48 am

This what I get. Seems OK to me!
Please send you PRG.

Serge
Attachments
aaaa.png
aaaa.png (9.82 KiB) Viewed 1030 times

User avatar
mol
Posts: 2713
Joined: Thu Sep 11, 2008 5:31 am
Location: Myszków, Poland
Has thanked: 81 times
Been thanked: 27 times
Contact:

Post by mol » Thu Dec 08, 2016 9:05 am

huiyi_ch wrote:Hello Dr. Claudio Soto
当我打开数据库(表),与之绑定的GRID 显示正常,但是当我对数据库进行过滤后,我发现符合条件的记录显示不正确.
When I open the database (table), with the binding of the GRID show normal, but when I filter the database, I found that the records are not displayed correctly.
jpeg1.jpgJPEG2.jpg
I included my sources and database in attachment in a zip-file.
I use WindowsXp, and installed HMG.3.4.3.Setup.exe.

Code: Select all

#include <hmg.ch>
Function Main
    MAKEDATA()
    DEFINE WINDOW MAIN AT 213 , 425;
		WIDTH 482 HEIGHT 350 VIRTUAL WIDTH Nil VIRTUAL HEIGHT Nil ;
		TITLE "Test grid control" ICON NIL MAIN CURSOR NIL
		
    DEFINE LABEL Label_1
        ROW    30
        COL    40
        WIDTH  120
        HEIGHT 24
        VALUE "Enter filter value"
        FONTNAME "Arial"
        FONTSIZE 9
        TOOLTIP ""
        ACTION Nil
        AUTOSIZE .F.
        BACKCOLOR NIL
        FONTCOLOR NIL
        RIGHTALIGN .T. 
    END LABEL

    DEFINE TEXTBOX Text_1
        ROW    30
        COL    180
        WIDTH  120
        HEIGHT 24
        FONTNAME "Arial"
        FONTSIZE 9
        TOOLTIP ""
        CASECONVERT NONE
        BACKCOLOR NIL
        FONTCOLOR NIL
        INPUTMASK "!!!!!"
        FORMAT Nil
        VALUE ""
    END TEXTBOX

    DEFINE BUTTON Button_1
        ROW    30
        COL    330
        WIDTH  100
        HEIGHT 28
        ACTION FILTER(MAIN.TEXT_1.VALUE)
        CAPTION "FILTER"
        FONTNAME "Arial"
        FONTSIZE 9
        TOOLTIP ""
        PICTURE Nil
        PICTALIGNMENT TOP
    END BUTTON

    DEFINE GRID Grid_1
        ROW    80
        COL    30
        WIDTH  420
        HEIGHT 210
        ITEMS { {""} }
        VALUE Nil
        WIDTHS {200,200 }
        HEADERS {"field1","field2"}
        FONTNAME "Arial"
        FONTSIZE 9
        TOOLTIP ""
        
        BACKCOLOR NIL
        FONTCOLOR NIL
        HEADERIMAGES Nil
        ROWSOURCE "test"
        COLUMNFIELDS {"AA","BB"}
        ALLOWAPPEND .F.
        ALLOWDELETE .F.
        BUFFERED .F.
        DYNAMICDISPLAY Nil
        ONSAVE Nil
        LOCKCOLUMNS 0
    END GRID

END WINDOW
        Main.Center
        Main.Activate

Return

function makedata()
  local astru:={{"AA","C",3,0},{"BB","C",5,0}}
  dbcreate("test.dbf",astru)
  use test new
  dbAppend()
  TEST->AA:="11"
  TEST->BB:="AAAAA"
  dbAppend()
  TEST->AA:="12"
  TEST->BB:="BBBBB"
  dbAppend()
  TEST->AA:="13"
  TEST->BB:="AAAAA"
  dbAppend()
  TEST->AA:="14"
  TEST->BB:="CCCCC"
  dbAppend()
  TEST->AA:="15"
  TEST->BB:="AAAAA"
   dbAppend()
  TEST->AA:="16"
  TEST->BB:="AAAAA"
  
  RETURN NIL
  
  FUNCTION FILTER(CVALUE)
  IF EMPTY(CVALUE)
    dbClearFilter()
  ELSE	 
    dbSETFilter({||TEST->BB==CVALUE})
  ENDIF
  TEST->(DBGOTOP())
  MAIN.GRID_1.REFRESH()
  RETURN NIL
  
test.rar


Best regards, HUIYI
IMHO, you should declare cValue as private variable of Main function or public variable.
In your code, cValue is local in Filter file - after returning to main form, filter on db is bad defined.
You can always change it to:

Code: Select all

oFilter := "{|| alltrim(Test->BB)=='" +alltrim(cValue) + "'}"
dbSetFilter(&oFilter)

huiyi_ch
Posts: 53
Joined: Sat May 21, 2016 5:27 am
Has thanked: 1 time
Been thanked: 7 times

Post by huiyi_ch » Thu Dec 08, 2016 9:48 am

serge_girard wrote:This what I get. Seems OK to me!
Please send you PRG.

Serge
Please enter "BBBBB", look at the output is correct?

huiyi_ch
Posts: 53
Joined: Sat May 21, 2016 5:27 am
Has thanked: 1 time
Been thanked: 7 times

Post by huiyi_ch » Thu Dec 08, 2016 10:02 am

mol wrote:
huiyi_ch wrote:Hello Dr. Claudio Soto
当我打开数据库(表),与之绑定的GRID 显示正常,但是当我对数据库进行过滤后,我发现符合条件的记录显示不正确.
When I open the database (table), with the binding of the GRID show normal, but when I filter the database, I found that the records are not displayed correctly.
jpeg1.jpgJPEG2.jpg
I included my sources and database in attachment in a zip-file.
I use WindowsXp, and installed HMG.3.4.3.Setup.exe.

Code: Select all

#include <hmg.ch>
Function Main
    MAKEDATA()
    DEFINE WINDOW MAIN AT 213 , 425;
		WIDTH 482 HEIGHT 350 VIRTUAL WIDTH Nil VIRTUAL HEIGHT Nil ;
		TITLE "Test grid control" ICON NIL MAIN CURSOR NIL
		
    DEFINE LABEL Label_1
        ROW    30
        COL    40
        WIDTH  120
        HEIGHT 24
        VALUE "Enter filter value"
        FONTNAME "Arial"
        FONTSIZE 9
        TOOLTIP ""
        ACTION Nil
        AUTOSIZE .F.
        BACKCOLOR NIL
        FONTCOLOR NIL
        RIGHTALIGN .T. 
    END LABEL

    DEFINE TEXTBOX Text_1
        ROW    30
        COL    180
        WIDTH  120
        HEIGHT 24
        FONTNAME "Arial"
        FONTSIZE 9
        TOOLTIP ""
        CASECONVERT NONE
        BACKCOLOR NIL
        FONTCOLOR NIL
        INPUTMASK "!!!!!"
        FORMAT Nil
        VALUE ""
    END TEXTBOX

    DEFINE BUTTON Button_1
        ROW    30
        COL    330
        WIDTH  100
        HEIGHT 28
        ACTION FILTER(MAIN.TEXT_1.VALUE)
        CAPTION "FILTER"
        FONTNAME "Arial"
        FONTSIZE 9
        TOOLTIP ""
        PICTURE Nil
        PICTALIGNMENT TOP
    END BUTTON

    DEFINE GRID Grid_1
        ROW    80
        COL    30
        WIDTH  420
        HEIGHT 210
        ITEMS { {""} }
        VALUE Nil
        WIDTHS {200,200 }
        HEADERS {"field1","field2"}
        FONTNAME "Arial"
        FONTSIZE 9
        TOOLTIP ""
        
        BACKCOLOR NIL
        FONTCOLOR NIL
        HEADERIMAGES Nil
        ROWSOURCE "test"
        COLUMNFIELDS {"AA","BB"}
        ALLOWAPPEND .F.
        ALLOWDELETE .F.
        BUFFERED .F.
        DYNAMICDISPLAY Nil
        ONSAVE Nil
        LOCKCOLUMNS 0
    END GRID

END WINDOW
        Main.Center
        Main.Activate

Return

function makedata()
  local astru:={{"AA","C",3,0},{"BB","C",5,0}}
  dbcreate("test.dbf",astru)
  use test new
  dbAppend()
  TEST->AA:="11"
  TEST->BB:="AAAAA"
  dbAppend()
  TEST->AA:="12"
  TEST->BB:="BBBBB"
  dbAppend()
  TEST->AA:="13"
  TEST->BB:="AAAAA"
  dbAppend()
  TEST->AA:="14"
  TEST->BB:="CCCCC"
  dbAppend()
  TEST->AA:="15"
  TEST->BB:="AAAAA"
   dbAppend()
  TEST->AA:="16"
  TEST->BB:="AAAAA"
  
  RETURN NIL
  
  FUNCTION FILTER(CVALUE)
  IF EMPTY(CVALUE)
    dbClearFilter()
  ELSE	 
    dbSETFilter({||TEST->BB==CVALUE})
  ENDIF
  TEST->(DBGOTOP())
  MAIN.GRID_1.REFRESH()
  RETURN NIL
  
test.rar


Best regards, HUIYI
IMHO, you should declare cValue as private variable of Main function or public variable.
In your code, cValue is local in Filter file - after returning to main form, filter on db is bad defined.
You can always change it to:

Code: Select all

oFilter := "{|| alltrim(Test->BB)=='" +alltrim(cValue) + "'}"
dbSetFilter(&oFilter)
在代码块中,可以使用局部变量的。GRID显示不正确的原因,可能是由于GRID CONTROL存在BUG!
In the code block, you can use local variables. GRID display is not the correct reason, may be due to the grid control has bug.

User avatar
serge_girard
Posts: 1698
Joined: Sun Nov 25, 2012 2:44 pm
DBs Used: 1 MySQL - MariaDB
2 DBF
Location: Belgium
Has thanked: 204 times
Been thanked: 31 times
Contact:

Post by serge_girard » Thu Dec 08, 2016 10:18 am

Huiyi,

Enter "BBBBB" gives correct output for me! BUT... sometimes 2 lines with BBBBB are shown when clicking on empty lines.
Claudio, I think it is a bug. See att.

Serge
Attachments
aaaa.png
aaaa.png (9.33 KiB) Viewed 1010 times

Post Reply

Who is online

Users browsing this forum: No registered users and 2 guests