Simple xBrowse edit ?

Simple xBrowse edit ?

Postby TimStone » Thu Oct 24, 2013 3: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: Select all  Expand view

                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
User avatar
TimStone
 
Posts: 2944
Joined: Fri Oct 07, 2005 1:45 pm
Location: Trabuco Canyon, CA USA

Re: Simple xBrowse edit ?

Postby nageswaragunupudi » Thu Oct 24, 2013 5: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: Select all  Expand view


   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: Select all  Expand view


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



Revised code should look like this
Code: Select all  Expand view


   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
User avatar
nageswaragunupudi
 
Posts: 10632
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: Simple xBrowse edit ?

Postby TimStone » Thu Oct 24, 2013 5: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: Select all  Expand view

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
User avatar
TimStone
 
Posts: 2944
Joined: Fri Oct 07, 2005 1:45 pm
Location: Trabuco Canyon, CA USA

Re: Simple xBrowse edit ?

Postby nageswaragunupudi » Thu Oct 24, 2013 5:38 pm

I can say that the inline editing works with TDatabase, with the above correction.

Test:

Code: Select all  Expand view

#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 := { || ::oDbf:Save() }

Note: This is included in fwh 13.09
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10632
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: Simple xBrowse edit ?

Postby TimStone » Thu Oct 24, 2013 5: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
User avatar
TimStone
 
Posts: 2944
Joined: Fri Oct 07, 2005 1:45 pm
Location: Trabuco Canyon, CA USA

Re: Simple xBrowse edit ?

Postby nageswaragunupudi » Thu Oct 24, 2013 5:56 pm

Will please revise your code in this manner?
Code: Select all  Expand view
  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: Select all  Expand view

 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
User avatar
nageswaragunupudi
 
Posts: 10632
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: Simple xBrowse edit ?

Postby TimStone » Thu Oct 24, 2013 6: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
User avatar
TimStone
 
Posts: 2944
Joined: Fri Oct 07, 2005 1:45 pm
Location: Trabuco Canyon, CA USA

Re: Simple xBrowse edit ?

Postby nageswaragunupudi » Thu Oct 24, 2013 6: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
User avatar
nageswaragunupudi
 
Posts: 10632
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: Simple xBrowse edit ?

Postby TimStone » Thu Oct 24, 2013 6: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
User avatar
TimStone
 
Posts: 2944
Joined: Fri Oct 07, 2005 1:45 pm
Location: Trabuco Canyon, CA USA

Re: Simple xBrowse edit ?

Postby nageswaragunupudi » Thu Oct 24, 2013 6:33 pm

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

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10632
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: Simple xBrowse edit ?

Postby TimStone » Thu Oct 24, 2013 6: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
User avatar
TimStone
 
Posts: 2944
Joined: Fri Oct 07, 2005 1:45 pm
Location: Trabuco Canyon, CA USA


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 74 guests