FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour xBrowse cell edit
Posts: 1091
Joined: Thu Nov 17, 2005 11:08 AM
xBrowse cell edit
Posted: Wed Dec 21, 2016 08:56 AM
In a xbrowse I have some columns defined in this way
Code (fw): Select all Collapse
  oCol = oBrw:AddCol()
   oCol:bStrData    = { || field->name }
   oCol:cHeader     = "Nome"
   oCol:nEditType   = EDIT_GET
   oCol:bOnPostEdit = { | oCol, xVal, nKey | makerep( "field->name", nkey, oBrw, xVal ) }
   oCol:nWidth      = 200

I receive a request: when I digit some characters into one cell and than I click with mouse
on another place of my program (lost focous) in makerep function xVar has no value.
If a exit from cell using the keyboard has the value.
How can I modify mo code in order to keep the entered value?
Bye
marco
Marco Boschi
info@marcoboschi.it
Posts: 2706
Joined: Fri Oct 07, 2005 01:50 PM
Re: xBrowse cell edit
Posted: Wed Dec 21, 2016 02:37 PM

Marco

I confirm this behavior as well .. unless you use <tab> or <enter> the input buffer is not captured especially if you get distracted and have to move the focus.

Rick Lipkin

Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: xBrowse cell edit
Posted: Thu Dec 22, 2016 03:49 AM
How can I modify mo code in order to keep the entered value?

This is not possible now. The moment Get loses focus, the Get ends().
Options available are either to lose the changes (default) or save the changes when Get loses focus. Former option is safe and second option can lead to erroneous input.
This is the present behavior.
And I may inform you that changing this behavior is not going to be easy.
Regards



G. N. Rao.

Hyderabad, India
Posts: 663
Joined: Mon Dec 05, 2005 11:22 PM
Re: xBrowse cell edit
Posted: Thu Dec 22, 2016 04:02 AM

Excel saves the value if you click on another cell while entering data. I tried using xbrowse on entry screen where I used tsbrowse before and users were complaining about not saving entry. They would not always remember to press enter or tab before the save button.

Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: xBrowse cell edit
Posted: Thu Dec 22, 2016 04:17 AM

oCol:lAutoSave may be set to .T.
or
oBrw:lAutoSaves may be set to .T.

Regards



G. N. Rao.

Hyderabad, India
Posts: 1091
Joined: Thu Nov 17, 2005 11:08 AM
Re: xBrowse cell edit
Posted: Thu Dec 22, 2016 10:29 AM
Code (fw): Select all Collapse
oCol:lAutoSave may be set to .T.

Oh Very Good!
Many thanks
Marco
Marco Boschi
info@marcoboschi.it
Posts: 375
Joined: Tue Feb 10, 2015 09:48 AM
Re: xBrowse cell edit
Posted: Thu Jun 15, 2017 09:49 AM
Hi,
I am trying with FWH 15.3 and lAutoSave does not works.
I modified xbrwedit.prg in this way
Code (fw): Select all Collapse
#include "FiveWin.ch" 
#include "XBrowse.ch" 

function Main() 

   local oWnd, oBrw, oCol 

   USE Customer 
   ZAP

   DEFINE WINDOW oWnd 
    
   @ 0, 0 XBROWSE oBrw OF oWnd ALIAS "Customer" 
    
   oBrw:lFastEdit = .T. 
    
   oCol = oBrw:AddCol() 
   oCol:bStrData    = { || Customer->First } 
   oCol:cHeader     = "First" 
   oCol:nEditType   = EDIT_GET 
   oCol:bOnPostEdit = { | oCol, xVal, nKey | If( RecCount() == 0, ( DbAppend(), oBrw:Refresh() ),), If( nKey == VK_RETURN, Customer->First := xVal,) } 
   oCol:lAutoSave   = .T.

   oCol = oBrw:AddCol() 
   oCol:bStrData    = { || Customer->Last } 
   oCol:cHeader     = "Last" 
   oCol:nEditType   = EDIT_GET 
   oCol:bOnPostEdit = { | oCol, xVal, nKey | If( RecCount() == 0, DbAppend(),), If( nKey == VK_RETURN, ( Customer->Last := xVal, DbAppend(), oBrw:Refresh() ),) } 
   oCol:lAutoSave   = .T.
    
   oBrw:CreateFromCode() 
    
   oWnd:oClient = oBrw 

   ACTIVATE WINDOW oWnd 

return nil


(added oCol:lAutoSave = .T.)

is there a bugfix in the newest version?

Thanks,
Antonino
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: xBrowse cell edit
Posted: Thu Jun 15, 2017 09:52 AM

What are you expecting from AutoSave?

Regards



G. N. Rao.

Hyderabad, India
Posts: 375
Joined: Tue Feb 10, 2015 09:48 AM
Re: xBrowse cell edit
Posted: Thu Jun 15, 2017 10:34 AM
I expecting that when write something during editing and you click outside the value is saved.
for example

I expecting that the value remains...
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: xBrowse cell edit
Posted: Thu Jun 15, 2017 10:39 AM

But your postedit block insists that the last key should be VK_RETURN.

I suggest coding XBROWSE fully in command style, using COLUMNS clause. You can see any of the many samples I posted in the forums. Everything will work the way expected. That is our officially recommended way of coding to get the full benefit of xbrowse.

Regards



G. N. Rao.

Hyderabad, India
Posts: 375
Joined: Tue Feb 10, 2015 09:48 AM
Re: xBrowse cell edit
Posted: Thu Jun 15, 2017 10:42 AM

and why the provided example does not works?....
It is not my postedit it is yours...

Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: xBrowse cell edit
Posted: Thu Jun 15, 2017 10:50 AM

I mean the code written for postedit block.

If we use COLUMNS syntax XBrowse automatically generates a bOnPostEdit codeblock.
I need to go out for a while
When I am back I will post a working sample

Regards



G. N. Rao.

Hyderabad, India
Posts: 375
Joined: Tue Feb 10, 2015 09:48 AM
Re: xBrowse cell edit
Posted: Thu Jun 15, 2017 11:26 AM
If I change the bOnPostEdit it works as expected, (replacing nKey == VK_RETURN with nKey != VK_ESCAPE)
But I am not able to do it in my code, I will check again.
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: xBrowse cell edit
Posted: Thu Jun 15, 2017 11:31 AM
We suggest this code;
Code (fw): Select all Collapse
#include "FiveWin.ch"

REQUEST DBFCDX

function Main()

   local oWnd, oBrw, oBar

   USE Customer NEW SHARED VIA "DBFCDX"

   DEFINE WINDOW oWnd TITLE FWVERSION
   DEFINE BUTTONBAR oBar OF oWnd SIZE 100,32

   @ 0, 0 XBROWSE oBrw OF oWnd ALIAS "Customer"  ;
      COLUMNS "First", "Last" ;
      FASTEDIT

   oBrw:nEditTypes   := EDIT_GET
   oBrw:lAutoSaves   := .t.

   oBrw:createFromCode()
   oWnd:oClient      := oBrw

   DEFINE BUTTON PROMPT "Add"    OF oBar ACTION oBrw:EditSource( .t. )
   DEFINE BUTTON PROMPT "Edit"   OF oBar ACTION oBrw:EditSource()
   DEFINE BUTTON PROMPT "Delte"  OF oBar ACTION oBrw:Delete()

   ACTIVATE WINDOW oWnd

return nil
Regards



G. N. Rao.

Hyderabad, India

Continue the discussion