Page 1 of 1

A problem TDatabase and xBrowse using < edit_get >

Posted: Sun Nov 17, 2019 12:56 pm
by ukoenig
Hello,

I noticed a problem saving values with xBrowse edit_get
using

Browser 1
oCustomer := TDatabase():Open( , c_Path + "Customer", "DBFCDX", .T. )

only field LAST is working with some extracode

the same using
Browser 2
USE customer NEW SHARED ALIAS CUST VIA 'DBFCDX'
edit_get is working

Code: Select all

WITH OBJECT oBrw1:First
      :nEditType = EDIT_GET 
END
WITH OBJECT oBrw1:Last
     :nEditType = EDIT_GET 
     :bOnPostEdit := {|o, v, n| IIF( n != VK_ESCAPE, ; 
          oCustomer:FieldPut( 3, v ), ), ; // Field no 3 defined for saving !!!
          oCustomer:Save(), oBrw1:RefreshCurrent() }
END
WITH OBJECT oBrw1:Street
     :nEditType = EDIT_GET 
END

 
2 testbrowser

@ 20,10 XBROWSE oBrw1 ;
COLUMNS "Id", 'First' , 'Last', 'Street', 'City' OF oDlg ;
SIZE -10,-160 PIXEL ;
COLSIZES "50, 120, 120, 110, 110" ;
DATASOURCE oCustomer

@ 130,10 XBROWSE oBrw2 ;
COLUMNS "Id", 'First' , 'Last', 'Street', 'City' OF oDlg ;
SIZE -10,-50 PIXEL ;
COLSIZES "50, 120, 120, 110, 110" ;
ALIAS 'CUST'

Image

where does the difference comes from

regards
Uwe :?:

Re: A problem TDatabase and xBrowse saving with edit_get

Posted: Sun Nov 17, 2019 1:33 pm
by nageswaragunupudi
Will work correctly if you remove bOnPostEdit.

Re: A problem TDatabase and xBrowse saving with edit_get

Posted: Sun Nov 17, 2019 1:47 pm
by ukoenig
Here is my complete test that can be used like it is from inside the sample-folder
Will work correctly if you remove bOnPostEdit.
bOnPostEdit is only included because otherwise in browser 1 ( tDatabase ) values are not saved !

Code: Select all

#include 'fivewin.ch'
#include 'ord.ch'
#include 'xbrowse.ch'

REQUEST DBFCDX

FUNCTION MAIN()
LOCAL oDlg, oBrw1, oBrw2, oFont, oBtn[3], oSay[2]
LOCAL oCustomer
LOCAL nColPos := 1, nRowPos := 1

LOCAL c_path := cFilePath(GetModuleFileName( GetInstance() ) ) 

USE customer NEW SHARED ALIAS CUST VIA 'DBFCDX'
GO TOP

oCustomer := TDatabase():Open( , c_Path + "Customer", "DBFCDX", .T. )
oCustomer:GoTop()

DEFINE FONT oFont NAME "TAHOMA" SIZE 0,-14

DEFINE DIALOG oDlg SIZE 800, 550 PIXEL ;
TITLE "XBrowse EDIT_GET" ;
FONT oFont
 
@ 5, 30 SAY oSay[1] PROMPT "Row :    " + LTRIM(STR(nRowPos))  SIZE 40, 10  PIXEL COLOR 0, 12124088 FONT oFont OF oDlg  
@ 5, 90 SAY oSay[2] PROMPT "Column :    " + LTRIM(STR(nColPos))  SIZE 60, 10  PIXEL COLOR 0, 12124088 FONT oFont OF oDlg  

@ 20,10 XBROWSE oBrw1 ;
COLUMNS "Id",  'First' , 'Last', 'Street', 'City' OF oDlg ;
SIZE -10,-160 PIXEL ;
PICTURES nil, nil, nil, nil, nil ;
COLSIZES "50, 120, 120, 110, 110" ;
DATASOURCE oCustomer ;
CELL LINES AUTOSORT NOBORDER FOOTERS 

oBrw1:bClrSelFocus      := { || { 0, 14540287 } } 
oBrw1:bClrSel               := { || { 0, 15132365 } } 
oBrw1:nMarqueeStyle     := 3
oBrw1:nRowHeight        := 25
oBrw1:nRecSelWidth      := 50
oBrw1:bRecSelHeader     := { |brw| "No." }  // or simply "SlNo"
oBrw1:bRecSelFooter     := { |brw| brw:nLen } // or Simpy any value
oBrw1:bRecSelData       := { |brw| brw:KeyNo }
oBrw1:lColChangeNotify  := .T.

WITH OBJECT oBrw1:First
    :nEditType = EDIT_GET  // doesn't save data !!!
END
WITH OBJECT oBrw1:Last
    :nEditType = EDIT_GET 
    :bOnPostEdit := {|o, v, n| IIF( n != VK_ESCAPE, ; 
                            oCustomer:FieldPut( 3, v ), ), ; 
                            oCustomer:Save(), oBrw1:RefreshCurrent() }
END
WITH OBJECT oBrw1:Street
    :nEditType = EDIT_GET  // doesn't save data !!!
END

WITH OBJECT oBrw1
      :nStretchCol   := 1
      :bChange := { | nRow, nCol, nKey | nColPos := oBrw1:SelectedCol():nCreationOrder, ;
                            nRowPos := oBrw1:Keyno(), ;
                            oSay[1]:Refresh(), oBrw2:Refresh(), ; 
                            oSay[2]:Refresh() }    

      :CreateFromCode()
END
 
// -------------------------

@ 130,10 XBROWSE oBrw2 ;
COLUMNS "Id",  'First' , 'Last', 'Street', 'City' OF oDlg ;
SIZE -10,-50 PIXEL ;
COLSIZES "50, 120, 120, 110, 110" ;
ALIAS 'CUST' ;
CELL LINES AUTOSORT NOBORDER FOOTERS 

oBrw2:bClrSelFocus      := { || { 0, 14540287 } } 
oBrw2:bClrSel               := { || { 0, 15132365 } } 
oBrw2:nMarqueeStyle     := 3
oBrw2:nRowHeight        := 25
oBrw2:nRecSelWidth      := 50
oBrw2:bRecSelHeader     := { |brw| "No." } 
oBrw2:bRecSelFooter     := { |brw| brw:nLen }  
oBrw2:bRecSelData       := { |brw| brw:KeyNo }
oBrw2:lColChangeNotify  := .T.

// works !!!
WITH OBJECT oBrw2:First
    :nEditType = EDIT_GET 
END
WITH OBJECT oBrw2:Last
    :nEditType = EDIT_GET 
END

WITH OBJECT oBrw2
      :nStretchCol   := 1
     :bChange := { | nRow, nCol, nKey | nColPos := oBrw2:SelectedCol():nCreationOrder, ;
                                                        nRowPos := oBrw2:Keyno(), ;
                                                        oSay[1]:Refresh(), oBrw1:Refresh(), ; 
                                                        oSay[2]:Refresh() }       

      :CreateFromCode()
END

@ 240, 340 BTNBMP oBtn[3] OF oDlg ;
SIZE 50, 20 PIXEL 2007 ; // B / H
PROMPT "&Exit" ;
ACTION oDlg:End() ;
FONT oFont  ;
CENTER

ACTIVATE DIALOG oDlg CENTERED

CLOSE DATABASE
RELEASE FONT oFont

RETURN NIL
 
regards
Uwe :?:

Re: A problem TDatabase and xBrowse using < edit_get >

Posted: Tue Nov 19, 2019 9:44 am
by ukoenig
both browser are working now and are synchron.
Only one get is used for all fields
Changing the get both browser are updated with the save-button.

Just one question :
with a double-click I can change the cellvalue
A return saves the new value and is visible in browser 1 as well.
Both browsers are updated.
How can I update the get as well as soon I use Return ?
The get is showing the new value only on row change

I tested a get-refresh but doesn't work

Code: Select all

// the get
@ 250, 175 GET oGet VAR cVar  SIZE 160, 15  PIXEL OF oDlg FONT oFont2 COLOR 255, 16769734 UPDATE

// the get-update from inside the browser
:bLClicked  := { || oCol := oBrw2:SelectedCol(), ; 
                           cVar := PADR( oCol:Value, 80, " " ), oGet:Refresh() }  

WITH OBJECT oBrw2:Street
     :nEditType = EDIT_GET 
     :bClrEdit := { || { CLR_BLACK, CLR_YELLOW }}
END

// the GET update on celledit return ?????

:PostMsg( WM_SETFOCUS )
:bKeyDown   := { | nKey, nFlags | If( nKey == VK_RETURN, ;
          ( oCol := oBrw2:SelectedCol(), ; 
            Eval( oBrw2:bChange ), ;
            cVar := PADR( oCol:Value, 80, " " ), ; // new get-value
            oGet:Refresh() ), ) }
 
Image

regards
Uwe :?: