XBrowse edit only one column

Re: XBrowse edit only one column

Postby damianodec » Thu Jul 11, 2019 1:27 pm

thank you!
FiveWin for xHarbour 17.09 - Sep. 2017 - Embarcadero C++ 7.00 for Win32
FWH 64 for Harbour 19.06 (MSVC++) Jun. 2019 - Harbour 3.2.0dev (r1904111533)
Visual Studio 2019 - Pelles C V.8.00.60 (Win64)
User avatar
damianodec
 
Posts: 414
Joined: Wed Jun 06, 2007 2:58 pm
Location: Italia

Re: XBrowse edit only one column

Postby Silvio.Falconi » Thu Jul 11, 2019 3:54 pm

Nages,
Code: Select all  Expand view

 @ 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 November 2023 - January 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
User avatar
Silvio.Falconi
 
Posts: 6772
Joined: Thu Oct 18, 2012 7:17 pm

Re: XBrowse edit only one column

Postby James Bott » Wed Aug 14, 2019 3:27 pm

Nages,

oBrw:Age:bOnChange := { |oCol, nOldVal| oBrw:Salary: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:QtyOrd:bOnChange := { | oCol | oBrw:extPrice: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
User avatar
James Bott
 
Posts: 4840
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA

Re: XBrowse edit only one column

Postby nageswaragunupudi » Wed Aug 14, 2019 4: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
User avatar
nageswaragunupudi
 
Posts: 10248
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: XBrowse edit only one column

Postby James Bott » Wed Aug 14, 2019 4:15 pm

Nages,

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

Code: Select all  Expand view
        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
User avatar
James Bott
 
Posts: 4840
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA

Re: XBrowse edit only one column

Postby James Bott » Wed Aug 14, 2019 4:22 pm

Nages,

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

Code: Select all  Expand view
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
User avatar
James Bott
 
Posts: 4840
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA

Re: XBrowse edit only one column

Postby Marc Venken » Wed Aug 14, 2019 4:48 pm

Code: Select all  Expand view

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.04 with Harbour
User avatar
Marc Venken
 
Posts: 1343
Joined: Tue Jun 14, 2016 7:51 am
Location: Belgium

Re: XBrowse edit only one column

Postby nageswaragunupudi » Wed Aug 14, 2019 5: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: Select all  Expand view
@ 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
User avatar
nageswaragunupudi
 
Posts: 10248
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: XBrowse edit only one column

Postby James Bott » Wed Aug 14, 2019 5:24 pm

Nages,

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

Code: Select all  Expand view
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
User avatar
James Bott
 
Posts: 4840
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA

Re: XBrowse edit only one column

Postby nageswaragunupudi » Wed Aug 14, 2019 5: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
User avatar
nageswaragunupudi
 
Posts: 10248
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: XBrowse edit only one column

Postby James Bott » Wed Aug 14, 2019 5:54 pm

Nages,

I am working on that right now.

James
FWH 18.05/xHarbour 1.2.3/BCC7/Windows 10
User avatar
James Bott
 
Posts: 4840
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA

Re: XBrowse edit only one column

Postby James Bott » 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
User avatar
James Bott
 
Posts: 4840
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA

Previous

Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: Google [Bot] and 85 guests