FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour Simple xBrowse edit ?
Posts: 3022
Joined: Fri Oct 07, 2005 01:45 PM
Simple xBrowse edit ?
Posted: Thu Oct 24, 2013 03:38 PM
I always use edit boxes with an xbrowse, but this time I want to do the editing of some columns directly on the browse.

The values for the columns is drawn from a data object ( database ).

Here is the code I am using:
Code (fw): Select all Collapse
                REDEFINE XBROWSE oLBx8 ID 496 OF oFld:aDialogs[7] 

                // Attach the database
                oLBx8:setoDBF( oInsp )
            
                add oCol to oLBx8 header "Pass" data oInsp:svcpas SIZE 40 ALIGN CENTER EDITABLE 
                oCol:setcheck( )
                add oCol to oLBx8 header "N/A" data oInsp:svcnap SIZE 40 ALIGN CENTER EDITABLE 
                oCol:setCheck( )
                add oCol to oLBx8 header "Code" data oInsp:svccod SIZE 100 ALIGN LEFT
                add oCol to oLBx8 header "Category" data oInsp:svccat SIZE 100 ALIGN LEFT
                add oCol to oLBx8 Header "Item" data oInsp:svcla1 SIZE 80 ALIGN LEFT
                add oCol to oLBx8 Header "Value" data oInsp:svcva1 SIZE 80 ALIGN LEFT EDITABLE 
                add oCol to oLBx8 Header "Item" data oInsp:svcla2 SIZE 80 ALIGN LEFT
                add oCol to oLBx8 Header "Value" data oInsp:svcva2 SIZE 80 ALIGN LEFT EDITABLE 
                add oCol to oLBx8 Header "Detail" data oInsp:svcdes SIZE 400 ALIGN LEFT


In column 1 and 2 I have logical fields and want to simply click on them to change the value ( or touch them on a touch screen device ).
On columns 6 & 8 I have small fields where I want to insert a value. If I click on them I can type in data but when I leave the field the data disappears.
The other columns are not to be edited.

So what do I need to add to make this work ? Thanks
Tim Stone
http://www.MasterLinkSoftware.com
http://www.autoshopwriter.com
timstone@masterlinksoftware.com
Using: FWH 23.10 with Harbour 3.2.0 / Microsoft Visual Studio Community 2022-24 32/64 bit
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: Simple xBrowse edit ?
Posted: Thu Oct 24, 2013 05:12 PM
There is a small bug in class TDatabase. Please make this correction.

I would request you to make this correction in tdatabase class, in \fwh\source\function\database.prg

In the METHOD SetXBrowse( .... ) CLASS TDataBase, you will find this code:
Code (fw): Select all Collapse
   WITH OBJECT oBrw
      :oDbf          := oDbf
      :bGoTop        := {|| oBrw:oDbf:GoTop() }
      < other lines like this>
      :bSeek         := { |c| oBrw:oDbf:Seek( c, , oBrw:lSeekWild ) }
   END



Please insert this line after :bSeek := .... and END
Code (fw): Select all Collapse
  :bSaveData := { || oBrw:oDbf:Save() }



Revised code should look like this
Code (fw): Select all Collapse
   WITH OBJECT oBrw
      :oDbf          := oDbf
      :bGoTop        := {|| oBrw:oDbf:GoTop() }
      < other lines like this>
      :bSeek         := { |c| oBrw:oDbf:Seek( c, , oBrw:lSeekWild ) }
      :bSaveData     := { || oBrw:oDbf:Save() }
   END



With this modification everything should work correctly.

This fix is included in FWH13.09.
Regards



G. N. Rao.

Hyderabad, India
Posts: 3022
Joined: Fri Oct 07, 2005 01:45 PM
Re: Simple xBrowse edit ?
Posted: Thu Oct 24, 2013 05:27 PM
I made the change but it does not resolve the issue.

1) I assume the checkbox setting, when clicked, should toggle the value. It doesn't do anything.
2) I am using tData, James Bott's derivation from tDatabase, to create the data object.
3) I am also using a REDEFINE from an RC control here. Here is the .rc code:
Code (fw): Select all Collapse
PRO100I DIALOG DISCARDABLE 0, 0, 648, 370
STYLE WS_CHILD|WS_VISIBLE
FONT 8, "Arial"
BEGIN
  CONTROL "", 496, "TXBrowse", WS_TABSTOP|0x00a00000, 10, 40, 628, 320
END


Making the changes directly on the grid is really key.
Tim Stone
http://www.MasterLinkSoftware.com
http://www.autoshopwriter.com
timstone@masterlinksoftware.com
Using: FWH 23.10 with Harbour 3.2.0 / Microsoft Visual Studio Community 2022-24 32/64 bit
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: Simple xBrowse edit ?
Posted: Thu Oct 24, 2013 05:38 PM
I can say that the inline editing works with TDatabase, with the above correction.

Test:

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

function Main()

local oDbf

USE CUSTOMER 
DATABASE oDbf

XBROWSER oDbf COLUMNS "FIRST", "CITY", "MARRIED", "AGE" FASTEDIT SETUP ( oBrw:Married:SetCheck() )

return nil


Now about TData class:
I do not know if TData is derived from the latest TDataBase class.
If not please make this change in xbrowse.prg in the method SetODbf(...)

Somewhere towards the end of the method SetODbf() in xbrowse
add this line

::bSaveData := { || ::Save() }

Note: This is included in fwh 13.09
Regards



G. N. Rao.

Hyderabad, India
Posts: 3022
Joined: Fri Oct 07, 2005 01:45 PM
Re: Simple xBrowse edit ?
Posted: Thu Oct 24, 2013 05:43 PM

tData is always built from the latest tDatabase ... because it is a subclass.

CLASS TData from TDatabase

Thus, when I do a rebuild of the program, it will always be deriving from the current tDatabase.

Tim

Tim Stone
http://www.MasterLinkSoftware.com
http://www.autoshopwriter.com
timstone@masterlinksoftware.com
Using: FWH 23.10 with Harbour 3.2.0 / Microsoft Visual Studio Community 2022-24 32/64 bit
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: Simple xBrowse edit ?
Posted: Thu Oct 24, 2013 05:56 PM
Will please revise your code in this manner?
Code (fw): Select all Collapse
   REDEFINE XBROWSE oLBx8 ID 496 OF oFld:aDialogs[7] DATASOURCE oInsp ;
      COLUMNS "SVCPASS", "SVCNAP", "SVCCOD", "SVCCAT", "SVCLA1", "SVCVA1", "SVCLA2", "SVCVA2", "SVCDES" ;
      HEADERS "Pass", "N/A", "Code", "Category", "Item", "Value", "Item", "Value", "Detail" ;
      COLSIZES 40,40,100,100,80,80,80,80,400 ;
      CELL LINES
      
   oLbx8:aCols[ 1 ]:SetCheck()
   oLbx8:aCols[ 2 ]:SetCheck()


In case we are using ADD TO oBrw syntax and need the values to be edited, we need to use setget codeblocks like this.

Code (fw): Select all Collapse
 add oCol to oLBx8 header "Pass" ;
 data { |x| If( x == nil, oInsp:svcpas, oInsp:svcpas := x } SIZE 40 ALIGN CENTER EDITABLE

Instead it is much easier to write the code using the syntax I suggested. In that case xbrowse constructs the SETGET codeblocks itself.

Please try my suggestion and let me know.

PS: Please check if I committed any spelling mistakes.
Regards



G. N. Rao.

Hyderabad, India
Posts: 3022
Joined: Fri Oct 07, 2005 01:45 PM
Re: Simple xBrowse edit ?
Posted: Thu Oct 24, 2013 06:09 PM

It displays, but is not editable ...

We want to toggle ( T or F ) columns 1 & 2, and edit values in 6 & 8.

Tim Stone
http://www.MasterLinkSoftware.com
http://www.autoshopwriter.com
timstone@masterlinksoftware.com
Using: FWH 23.10 with Harbour 3.2.0 / Microsoft Visual Studio Community 2022-24 32/64 bit
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: Simple xBrowse edit ?
Posted: Thu Oct 24, 2013 06:22 PM

Sorry,

Please also add this line after the code I posted above

oLbx8:nEditTypes := EDIT_GET

Can I wait for your response please?

Regards



G. N. Rao.

Hyderabad, India
Posts: 3022
Joined: Fri Oct 07, 2005 01:45 PM
Re: Simple xBrowse edit ?
Posted: Thu Oct 24, 2013 06:30 PM

Thank you. It now works perfectly.

As always, your help is greatly appreciated. Thanks for all you contribute to the FWH community.

Tim Stone
http://www.MasterLinkSoftware.com
http://www.autoshopwriter.com
timstone@masterlinksoftware.com
Using: FWH 23.10 with Harbour 3.2.0 / Microsoft Visual Studio Community 2022-24 32/64 bit
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: Simple xBrowse edit ?
Posted: Thu Oct 24, 2013 06:33 PM

I am glad it worked and thank you for your patience and cooperation.

Regards



G. N. Rao.

Hyderabad, India
Posts: 3022
Joined: Fri Oct 07, 2005 01:45 PM
Re: Simple xBrowse edit ?
Posted: Thu Oct 24, 2013 06:46 PM

Any idea when 13.09 will be out ?

Tim Stone
http://www.MasterLinkSoftware.com
http://www.autoshopwriter.com
timstone@masterlinksoftware.com
Using: FWH 23.10 with Harbour 3.2.0 / Microsoft Visual Studio Community 2022-24 32/64 bit

Continue the discussion