FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour TxBrowse - Edit
Posts: 190
Joined: Tue Mar 14, 2006 01:59 AM
TxBrowse - Edit
Posted: Wed Mar 11, 2009 01:48 AM
Hello all,

when editing a cell and leaving it with the arrow keys, the new value is correctly stored.
Code (fw): Select all Collapse
oBrw:aCols[1]:bOnPostEdit   := {|o,x| aTemp[ oBrw:nArrayAt, 1 ] := x }

when leaving it by a mouse click on another cell, the old value is restored in that cell (like by pressing ESC)
I would like to save it however, like in a real spredsheet.
Tried with or without lFastEdit, same behaviour.

TIA
Davide
FWH 9.02 - xH 1.1 - Bcc 55
Posts: 2365
Joined: Wed Nov 02, 2005 11:46 PM
Re: TxBrowse - Edit
Posted: Wed Mar 11, 2009 05:42 AM
Hello Davide...

xBrowse dont have this feature but you can make that

if you want test first download example
in the example i did config only columns 1 & 2 but if you want all columns you can do

http://www.sitasoft.com/fivewin/test/testxbr2.rar

open xbrowse.prg

add new data in TXBrwColumn class
Code (fw): Select all Collapse
DATA lAutoSave AS LOGICAL INIT .f.


find METHOD CancelEdit() CLASS TXBrowse
inside this method find
Code (fw): Select all Collapse
      for nFor := 1 to nLen
         oCol := ::aCols[ nFor ]
         if oCol:oEditGet != nil
            oCol:oEditGet:VarPut( Eval( oCol:bEditValue ) )
            oCol:oEditGet:bValid = nil
            oCol:PostEdit()
         endif
         if oCol:oEditLbx != nil
            oCol:oEditLbx:End()
         endif
      next


replace with

Code (fw): Select all Collapse
      for nFor := 1 to nLen
         oCol := ::aCols[ nFor ]
         if oCol:oEditGet != nil
            oCol:oEditGet:VarPut( Eval( oCol:bEditValue ) )
            oCol:oEditGet:bValid = nil
            if oCol:lAutoSave             //new line
               oCol:oEditGet:Assign()  //new line
            endif                               //new line
            oCol:PostEdit()
         endif
         if oCol:oEditLbx != nil
            oCol:oEditLbx:End()
         endif
      next


it's all...

Code (fw): Select all Collapse
#include "fivewin.ch"
#include "xbrowse.ch"

function TestMain()

   local oWnd
   local oBrw

   
   local aArray := {}
   
   DEFINE WINDOW oWnd TITLE "Testing Empty Array xBrowse" 
   
  
   if empty( aArray )                          
      aArray := {{"one","two","three","four"},;
        {"one","two","three","four"},;
        {"one","two","three","four"},;
        {"one","two","three","four"}}    
   endif

   
   @ 0,0 XBROWSE oBrw OF oWnd ;
      COLUMNS {1,2,3,4} ;
      HEADERS {"uno","dos","tres","cuatro"} ;
      array aArray LINES CELL fastedit
   
   oBrw:aCols[ 1 ]:lAutoSave := .t.
   oBrw:aCols[ 2 ]:lAutoSave := .t.
   
   
   aeval( oBrw:aCols, { |oCols| oCols:nEditType := EDIT_GET } )
   
   oWnd:oClient := oBrw
   
   oBrw:createfromcode()
   
   activate window oWnd 
   
return nil
Posts: 4840
Joined: Fri Nov 18, 2005 04:52 PM
Re: TxBrowse - Edit
Posted: Wed Mar 11, 2009 05:49 AM

Antonio,

>when leaving it by a mouse click on another cell, the old value is restored in that cell (like by pressing ESC). I would like to save it however, like in a real spredsheet.

This is the behavior every users expects. I suggest making is as the default behavior of TXBrowse. I don't think it will break any apps since users will be glad if it now works that way.

Regards,
James

FWH 18.05/xHarbour 1.2.3/BCC7/Windows 10
Posts: 190
Joined: Tue Mar 14, 2006 01:59 AM
Re: TxBrowse - Edit
Posted: Wed Mar 11, 2009 11:26 PM
James Bott wrote:This is the behavior every users expects. I suggest making is as the default behavior of TXBrowse. I don't think it will break any apps since users will be glad if it now works that way.

I agree. Apart dinos like me, most of the customers doesn't use the keyboard so much and moves between the cells with the mouse, then they call asking why the program doesn't save the data they type.
I vote to make this the default behaviour too.
Hi,
Davide
Posts: 2365
Joined: Wed Nov 02, 2005 11:46 PM
Re: TxBrowse - Edit
Posted: Wed Mar 11, 2009 11:30 PM

Hello Davide

do you test my change?

worked ok?

Posts: 190
Joined: Tue Mar 14, 2006 01:59 AM
Re: TxBrowse - Edit
Posted: Thu Mar 12, 2009 01:01 AM
Dear Daniel,
Daniel Garcia-Gil wrote:do you test my change?

thank you for your help. Unfortunately I haven't yet had time to test it, but I'll do it surely.
Actually I'm busy on reapplying my custom changes to other classes. In fact I purchased the FTDN in December, but installed it only yesterday because each time I upgrade I have to redo that job.
That's why I hope Antonio will accept James's suggestion. The less custom classes I use, the simpler is for me upgrading FWH.

I'll test it asap, and I'll let you know.

Thanks again.
Davide
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: TxBrowse - Edit
Posted: Tue Mar 17, 2009 09:29 PM

James,

Yes, we are going to include Daniel's changes in next FWH build :-)

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 190
Joined: Tue Mar 14, 2006 01:59 AM
Re: TxBrowse - Edit
Posted: Sat Mar 21, 2009 05:39 PM
Antonio,
Antonio Linares wrote:Yes, we are going to include Daniel's changes in next FWH build :-)

when exiting the last cell with the TAB key I receive:
MsgStop( "::bPastEof not defined","Fivewin: Class TXBrowse" )
I'm not willing to append data to the array. Could you please remove that message too ? (BTW, it's just something for the programmer, not the end user)
Thanks,
Davide
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: TxBrowse - Edit
Posted: Sat Mar 21, 2009 06:25 PM

With the above change, the contents are saved even when Eval( oCol:bEditValid ) is false.

Regards



G. N. Rao.

Hyderabad, India
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: TxBrowse - Edit
Posted: Sat Mar 21, 2009 06:44 PM

It is true that xbrowse behaves differently than excel in this regard.

I have the following suggestions for consideration of our friends here.

  1. lAutosave can be a setting for the entire browse than for individual columns. Even better it is something like a class variable or a global setting. We like to offer consitant behaviour across the entire application or atleast within the same browse. It may not be desirable to have different columns in different browses behaving differently.

  2. Save only if the oCol:bEditValid evaluates to true.

  3. Save only when the user clicks on some other column in the same browse, but not otherwise. Half way through editing the user may go to some other window like a help window or see some other application or window for some information or scroll the browse up or down to refer to some information with a view to continue the edit. If xbrowse has to behave like excel, the edit has to remain the same edit poition when he comes back after he refers to other information / after other operation.

The danger with the present change is that if the user does anything ( referring to information in some help window or other application ) the partly edited value is saved. This is not what the user expects. He expects to continue and complete the edit when he comes back to the browse.

If we like to make this compatible with excel, we need to do it safely like excel. This may involve more work but desirable.

Regards



G. N. Rao.

Hyderabad, India
Posts: 2365
Joined: Wed Nov 02, 2005 11:46 PM
Re: TxBrowse - Edit
Posted: Sat Mar 21, 2009 07:18 PM

nageswaragunupudi...

thank you... good suggestions...

Posts: 2365
Joined: Wed Nov 02, 2005 11:46 PM
Re: TxBrowse - Edit
Posted: Sun Mar 22, 2009 04:24 AM
Rao...

Thank You for all suggestions

1. lAutosave can be a setting for the entire browse than for individual columns. Even better it is something like a class variable or a global setting. We like to offer consitant behaviour across the entire application or atleast within the same browse. It may not be desirable to have different columns in different browses behaving differently.

i leave this change for individual column no entry browse.... for this way you have more control over browse ( programer level ).... But, if user prefer a global data, we 'll do change

2. Save only if the oCol:bEditValid evaluates to true.

yes... you have reason... this point is solved


3. Save only when the user clicks on some other column in the same browse, but not otherwise. Half way through editing the user may go to some other window like a help window or see some other application or window for some information or scroll the browse up or down to refer to some information with a view to continue the edit. If xbrowse has to behave like excel, the edit has to remain the same edit poition when he comes back after he refers to other information / after other operation.

This point is solved...
when user click over other control in same aplication the data is saved but when user click over other aplication the cell will continue in edition status...

this point have a limitation, the get do not got focus inmediatly, first you have to press any key (no esc)

this change will be added in the next build...

I would like talk with you for more suggestions/opinions
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: TxBrowse - Edit
Posted: Sun Mar 22, 2009 05:12 AM

Nice.
Would you mind sharing your revised CancelEdit method ?

Regards



G. N. Rao.

Hyderabad, India
Posts: 2365
Joined: Wed Nov 02, 2005 11:46 PM
Re: TxBrowse - Edit
Posted: Sun Mar 22, 2009 07:35 AM
Rao..

i did so many change in various class

it was changed in CancelEdit Method...

Code (fw): Select all Collapse
      if ::lEditMode
      nLen := Len( ::aCols )
      for nFor := 1 to nLen
         oCol := ::aCols[ nFor ]
         if oCol:oEditGet != nil
            if oCol:nEditType < EDIT_DATE .and. !oCol:lAutoSave
               oCol:oEditGet:VarPut( Eval( oCol:bEditValue ) )
            elseif oCol:lAutoSave
               if oCol:oEditGet:lValid() .and. oCol:oEditGet:nLastKey != VK_ESCAPE
                  oCol:oEditGet:Assign()
               else
                  oCol:oEditGet:VarPut( Eval( oCol:bEditValue ) )
               endif
            endif
            oCol:oEditGet:bValid = nil
            oCol:PostEdit()
         endif
         if oCol:oEditLbx != nil
            oCol:oEditLbx:End()
         endif
      next

      ::lEditMode := .f.
   endif


Other changes should be available in the next FWH Build

Please check this sample, valid = only accept negative number
http://www.sitasoft.com/fivewin/test/test1.rar
Posts: 2365
Joined: Wed Nov 02, 2005 11:46 PM
Re: TxBrowse - Edit
Posted: Mon Mar 23, 2009 05:12 AM
Davide wrote:Antonio,
Antonio Linares wrote:Yes, we are going to include Daniel's changes in next FWH build :-)

when exiting the last cell with the TAB key I receive:
MsgStop( "::bPastEof not defined","Fivewin: Class TXBrowse" )
I'm not willing to append data to the array. Could you please remove that message too ? (BTW, it's just something for the programmer, not the end user)
Thanks,
Davide


Hello Davide...
from december 2008 build (8.12) xbrowse have a new data lAutoAppend, default value = .t. if you want not append more row automaticly , set lAutoAppend := .f.