FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour XBrowse edit only one column
Posts: 434
Joined: Wed Jun 06, 2007 02:58 PM
Re: XBrowse edit only one column
Posted: Thu Jul 11, 2019 01:27 PM

thank you!

FiveWin for xHarbour 24.02 - Feb. 2024 - Embarcadero C++ 7.60 for Win32 Copyright (c) 1993-2023

FWH 64 for Harbour 19.06 (MSVC++) Jun. 2019 - Harbour 3.2.0dev (r1904111533)

Visual Studio 2019 - Pelles C V.8.00.60 (Win64)
Posts: 7318
Joined: Thu Oct 18, 2012 07:17 PM
Re: XBrowse edit only one column
Posted: Thu Jul 11, 2019 03:54 PM
Nages,
Code (fw): Select all Collapse
 @ 540, 20 BUTTON "SAVE"   SIZE 150,30 PIXEL OF oDlg ;
          ACTION ( AEval( aItems, { |o| o:Save() } ), oDlg:End() )


if i erase one rows on aItems, then what i save ?
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)

I use : FiveWin for Harbour March-April 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
Posts: 4840
Joined: Fri Nov 18, 2005 04:52 PM
Re: XBrowse edit only one column
Posted: Wed Aug 14, 2019 03:27 PM
Nages,

oBrw:Age:bOnChange := { |oCol, nOldVal| oBrw:VarPut( oCol:Value * <yourcalculation> ) }


I need to do something similar. I need to update the ExtPrice colum with Cost * QtyOrd but I have not been able to figure out the syntax. When I try a similar syntax (also using an array), it errors out:

// Update line item total
oBrw:bOnChange := { | oCol | oBrw:VarPut( oCol:Cost * oCol:QtyOrd ) }

Error description: Error BASE/1004 Message not found: TXBROWSE:QTYORD


Even this errors out with the same error:

msgInfo( oBrw:QtyOrd, "oBrw:QtyOrd")

Any ideas?
FWH 18.05/xHarbour 1.2.3/BCC7/Windows 10
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: XBrowse edit only one column
Posted: Wed Aug 14, 2019 04:05 PM

We can use oBrw:QtyOrd, if one of the column header is "qtyord"
This returns column object

Can you please give me a list of all your headers and tell me your formula in terms of "headers" as if Headers are the variables.
Then I will suggest the solution, with proper explanation

Is it ok?

All the following expressions return the column object:

oBrw:aCols[ <nCurrentlyVisibleOrde> ] // not recommended because at runtime we do not know which colums is where
oBrw:<cheader>
oBrw:oCol( "cheader" )
oBrw:oCol( <nCreationOrder> )

Once we have the column object,

oColObject:Value --> gives the value
oColObject:VarPut ( uNewValue ) not only assigns the new value but also adjusts totals, writes data to table, and everying else.

Regards



G. N. Rao.

Hyderabad, India
Posts: 4840
Joined: Fri Nov 18, 2005 04:52 PM
Re: XBrowse edit only one column
Posted: Wed Aug 14, 2019 04:15 PM
Nages,

I am not sure exactly what you are looking for, but this is the code for the browse:

Code (fw): Select all Collapse
         aItems:= oSalesOrder:aItems  // use a copy of the line-items

         @ 3,1 XBROWSE oBrw OF oDlg ;
            DATASOURCE aItems ;
            COLUMNS "Itemno","Descrip","Cost","Qtyord","ExtPrice";
            HEADERS "Item No", "Description","Cost","Qty Ordered","Total" ;
            COLSIZES 50,140,70,70,70 ;
            PICTURES "999";
            SIZE 300,130 
            //COLORS CLR_WHITE, CLR_BLUE
      
            oBrw:nRowHeight       := 25
            oBrw:lRecordSelector  := .f.
           // oBrw:nStretchCol      := STRETCHCOL_LAST
            oBrw:nRowDividerStyle := LINESTYLE_LIGHTGRAY
            oBrw:nColDividerStyle := LINESTYLE_LIGHTGRAY 

            oBrw:lFastEdit := .T.
            oBrw:aCols[ 4 ]:nEditType := EDIT_GET
            
            // Update line item total and sales order total
            // Errors out with: Error description: Error BASE/1004  Message not found: TXBROWSE:QTYORD
           //msgInfo( oBrw:Qtyord, "oBrw:qtyord") // errors out 
            oBrw:qtyord:bOnChange := { |oCol| oBrw:extPrice:VarPut( oCol:cost * oCol:qtyord ) }
      
            oBrw:nColSel:= 4 //oBrw:oCol( "QtyOrd" ):nCreationOrder
      
            oBrw:CreateFromCode()


There are more columns in the array (aItems) that are not used in the browse.

James
FWH 18.05/xHarbour 1.2.3/BCC7/Windows 10
Posts: 4840
Joined: Fri Nov 18, 2005 04:52 PM
Re: XBrowse edit only one column
Posted: Wed Aug 14, 2019 04:22 PM
Nages,

Here are all the fieldnames in the database and in aItems:

Code (fw): Select all Collapse
INVNO       C  8    0
INVDTE      D  8    0
CUSTNO      C  4    0
ITEMNO      C  6    0
DESCRIP     C  20   0
COST        N  7    2
RETAIL      N  7    2
PACK        N  4    0
SALEQTY     N  1    0
UOM         C  2    0
QTYORD      N  3    0
QTYSHP      N  3    0
EXTPRICE    N  8    2
CLASS       C  1    0
TAXABLE     L  1    0
DEPT        C  1    0
ARTYPE      C  1    0
PLU         C  11   0
Record length: 96


James
FWH 18.05/xHarbour 1.2.3/BCC7/Windows 10
Posts: 1487
Joined: Tue Jun 14, 2016 07:51 AM
Re: XBrowse edit only one column
Posted: Wed Aug 14, 2019 04:48 PM
Code (fw): Select all Collapse
oBrw:QtyOrd:bOnChange := { | oCol | oBrw:extPrice:VarPut( oCol:Cost * oCol:QtyOrd ) }


       COLUMNS "Itemno","Descrip","Cost","Qtyord","ExtPrice";
       HEADERS "Item No", "Description","Cost","Qty Ordered","Total" ;


Your column is Qtyord, but it needs to be the header. Xbrowse needs the headers to do the job.

oCol:qty ordered

Mayby the space between (Qty Ordered) has to be removed. (Not sure)
Marc Venken

Using: FWH 23.08 with Harbour
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: XBrowse edit only one column
Posted: Wed Aug 14, 2019 05:01 PM
I understand that "aItems" is a 2-dimensional array consisting of values extracted from all the fields of the the DBF in the same order.
In that case
Code (fw): Select all Collapse
@ 3,1 XBROWSE oBrw OF oDlg ;
   DATASOURCE aItems ;
   COLUMNS 4, 5, 6, 11, 13 ; // "Itemno","Descrip","Cost","Qtyord","ExtPrice"
   HEADERS "Item No", "Description","Cost","Qty Ordered","Total" ;
   COLSIZES 50,140,70,70,70 ;
   PICTURES "999", nil, "9,999.99", "999", "99,999.99" ;
   SIZE 300,130 

oBrw:QtyOrdered:bOnChange := { |oCol| oBrw:Total:VarPut( oBrw:cost:Value * oBrw:QtyOrdered:Value ) }


* edited and mistakes corrected. Please note
Regards



G. N. Rao.

Hyderabad, India
Posts: 4840
Joined: Fri Nov 18, 2005 04:52 PM
Re: XBrowse edit only one column
Posted: Wed Aug 14, 2019 05:24 PM
Nages,

Hmm, that is not working for me. Here is what the browse looks like with your code:

Code (fw): Select all Collapse
ItemNo Description Cost QtyOrd ExtPrice
3      TLINEITEMS
4      TLINEITEMS
5      TLINEITEMS


Before it was displaying the data correctly.

James
FWH 18.05/xHarbour 1.2.3/BCC7/Windows 10
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: XBrowse edit only one column
Posted: Wed Aug 14, 2019 05:27 PM

Is it possible to make a small sample and send to my email including the dbf?
Looks like I am unable to understand your exact requirement correctly.

nageswaragunupudi[at]gmail[dot]com

Regards



G. N. Rao.

Hyderabad, India
Posts: 4840
Joined: Fri Nov 18, 2005 04:52 PM
Re: XBrowse edit only one column
Posted: Wed Aug 14, 2019 05:54 PM

Nages,

I am working on that right now.

James

FWH 18.05/xHarbour 1.2.3/BCC7/Windows 10
Posts: 4840
Joined: Fri Nov 18, 2005 04:52 PM
Re: XBrowse edit only one column
Posted: Wed Aug 14, 2019 11:51 PM

Nages,

Solved!

Originally this was the suggested code for updating the Total field:

  oBrw:QtyOrdered:bOnChange := { |oCol| oBrw:Total:VarPut( oCol:Cost:Value * oCol:QtyOrdered:Value ) }

However the above errors out.

This is working:

 oBrw:QtyOrdered:bOnChange := { || oBrw:Total:VarPut( oBrw:Cost:Value * oBrw:QtyOrdered:Value ) }

It seems you don't need to use the column object ( oCol ) at all.

Thanks for all the help.

James

FWH 18.05/xHarbour 1.2.3/BCC7/Windows 10

Continue the discussion