Xbrowse Edit Help
- Richard Chidiak
- Posts: 946
- Joined: Thu Oct 06, 2005 7:05 pm
- Location: France
- Contact:
Xbrowse Edit Help
Hello
I have a problem with xbrowse Edit, look like a bug
if i use the following syntax :
oCol:bStrData := {|| ALLTRIM(TRANSFORM((FUSER)->TTC,"@Z 999 999 999.99")) } Edit can not occur if the value is 0 there is no way to type something in the column, Edit-type is 1
If i remove the alltrim, then everything works OK
I need the alltrim as i use an underline font ,
I have been searching since a while in xbrowse.prg without success, probably missed something. Any help is appreciated
Thanks
Richard
I have a problem with xbrowse Edit, look like a bug
if i use the following syntax :
oCol:bStrData := {|| ALLTRIM(TRANSFORM((FUSER)->TTC,"@Z 999 999 999.99")) } Edit can not occur if the value is 0 there is no way to type something in the column, Edit-type is 1
If i remove the alltrim, then everything works OK
I need the alltrim as i use an underline font ,
I have been searching since a while in xbrowse.prg without success, probably missed something. Any help is appreciated
Thanks
Richard
- Richard Chidiak
- Posts: 946
- Joined: Thu Oct 06, 2005 7:05 pm
- Location: France
- Contact:
Re: Xbrowse Edit Help
I found where the problem comes from
Method edit(nkey)
DEFAULT ::cEditPicture := ""
uValue := Eval( ::bEditValue )
uValue in my case is a string length 0 , Edit can not happen
i have added the following
IF LEN(UVALUE) = 0 // CHIDIAK
UVALUE := REPLICATE(" ",15)
ENDIF
Now it works OK , i am sure there is another way to "fill" uvalue , maybe Antonio ?
Note ceditpicture has always been set
HTH
Richard
Method edit(nkey)
DEFAULT ::cEditPicture := ""
uValue := Eval( ::bEditValue )
uValue in my case is a string length 0 , Edit can not happen
i have added the following
IF LEN(UVALUE) = 0 // CHIDIAK
UVALUE := REPLICATE(" ",15)
ENDIF
Now it works OK , i am sure there is another way to "fill" uvalue , maybe Antonio ?
Note ceditpicture has always been set
HTH
Richard
- nageswaragunupudi
- Posts: 8017
- Joined: Sun Nov 19, 2006 5:22 am
- Location: India
- Contact:
To use the edit features of xbrowse, this is the recommended way:
Code: Select all
oCol:bEditvalue := { || FUSER->TTC }
oCol:cEditPicture := "@Z 999 999 999.99"
oCol:nEditType := EDIT_GET
oCol:bStrData := { || Transform( FUSER->TTC, "@Z 999 999 999.99" }
oCol:bPostEdit := { | oCol, uValue, nLastKey | If( nLastKey == 13, FUSER->TTC := uValue, nil ) }
Regards
G. N. Rao.
Hyderabad, India
G. N. Rao.
Hyderabad, India
- nageswaragunupudi
- Posts: 8017
- Joined: Sun Nov 19, 2006 5:22 am
- Location: India
- Contact:
If the above code looks complex or seems to be more time consuming to write, it is simpler to use the command
Code: Select all
ADD TO oBrw DATA FUSER->TTC PICTURE "@Z 999 999 999.99" ;
EDITABLE ;
ON EDIT { | oCol, uValue, nLastKey | If( nLastKey == 13, FUSER->TTC := uValue, nil ) }
Regards
G. N. Rao.
Hyderabad, India
G. N. Rao.
Hyderabad, India
- Richard Chidiak
- Posts: 946
- Joined: Thu Oct 06, 2005 7:05 pm
- Location: France
- Contact:
nageswaragunupudi wrote:To use the edit features of xbrowse, this is the recommended way:Code: Select all
oCol:bEditvalue := { || FUSER->TTC } oCol:cEditPicture := "@Z 999 999 999.99" oCol:nEditType := EDIT_GET oCol:bStrData := { || Transform( FUSER->TTC, "@Z 999 999 999.99" } oCol:bPostEdit := { | oCol, uValue, nLastKey | If( nLastKey == 13, FUSER->TTC := uValue, nil ) }
Is there a way to call edit without double clicking the column? If you know METHOD lEditCol( nCol, uVar, cPicture, bValid, nClrFore, nClrBack, ;
cMsg, cError ) of TCBrowse .
Thanks
A.S.K
- nageswaragunupudi
- Posts: 8017
- Joined: Sun Nov 19, 2006 5:22 am
- Location: India
- Contact:
- nageswaragunupudi
- Posts: 8017
- Joined: Sun Nov 19, 2006 5:22 am
- Location: India
- Contact:
Please try oCol:Edit()
I am not doing that for this reason. In the earlier browses, we were invoiking lEdit in response to some user action. In other words, Edit happens only in response to some user action. Earlier we had to deal with the user actions ourselves and decide in our code whether or not and when to invoke the edit method.
Xbrowse takes away that responsibility from the programmer. The browse responds to the user actions once we set the Data of the column and browse objects. This simplifies our coding.
Even if we use oCol:Edit() through our code, when do we invoke the edit? We ourselves watch the key strokes in our code and the decide to invoke oCol:Edit() ( or lEdit in ealier browses). Instead, is it not more convinient for us to code our business logic only, leaving the job of watching events / keystrokes and responding appropriately to the browse object itself?
I am not doing that for this reason. In the earlier browses, we were invoiking lEdit in response to some user action. In other words, Edit happens only in response to some user action. Earlier we had to deal with the user actions ourselves and decide in our code whether or not and when to invoke the edit method.
Xbrowse takes away that responsibility from the programmer. The browse responds to the user actions once we set the Data of the column and browse objects. This simplifies our coding.
Even if we use oCol:Edit() through our code, when do we invoke the edit? We ourselves watch the key strokes in our code and the decide to invoke oCol:Edit() ( or lEdit in ealier browses). Instead, is it not more convinient for us to code our business logic only, leaving the job of watching events / keystrokes and responding appropriately to the browse object itself?
Regards
G. N. Rao.
Hyderabad, India
G. N. Rao.
Hyderabad, India
nageswaragunupudi wrote:Please try oCol:Edit()
I am not doing that for this reason. In the earlier browses, we were invoiking lEdit in response to some user action. In other words, Edit happens only in response to some user action. Earlier we had to deal with the user actions ourselves and decide in our code whether or not and when to invoke the edit method.
Xbrowse takes away that responsibility from the programmer. The browse responds to the user actions once we set the Data of the column and browse objects. This simplifies our coding.
Even if we use oCol:Edit() through our code, when do we invoke the edit? We ourselves watch the key strokes in our code and the decide to invoke oCol:Edit() ( or lEdit in ealier browses). Instead, is it not more convinient for us to code our business logic only, leaving the job of watching events / keystrokes and responding appropriately to the browse object itself?
There is a BIG difference if you use oCol:Edit() with window and dialog. With dialog witch I am interested for is not working but with window works fine.
regards ,
A.S.K
- nageswaragunupudi
- Posts: 8017
- Joined: Sun Nov 19, 2006 5:22 am
- Location: India
- Contact:
The bellow example is taken from testxbrw.prg I made some changes and here it is:nageswaragunupudi wrote:Though I never use oCol:Edit() directly from code, for your sake I just now tested calling oCol:Edit() of a column in TXBrowse in Dialog. It is working fine for me. I would request you to give it a try once more.
Code: Select all
STATIC FUNCTION AutoEdit( oWnd )
local oChild, oBrw, oCol
local nFor
DEFINE window oChild TITLE "Auto edit browse"
oBrw := TXBrowse():New( oWnd )
oBrw:nColDividerStyle := LINESTYLE_BLACK
oBrw:nRowDividerStyle := LINESTYLE_BLACK
oBrw:lColDividerComplete := .t.
oBrw:SetRDD()
oBrw:CreateFromCode()
oCol := oBrw:aCols[ 1 ]
oCol:nEditType := 1
oCol:bOnPostEdit := {|o, v, n| iif( n != VK_ESCAPE, FieldPut( o:nCreationOrder, v ), ) }
ACTIVATE window oChild ON INIT (oBrw:nTop():=0,oBrw:nLeft():=0,oBrw:nWidth():=oChild:nWidth(),oBrw:nHeight():=oChild:nHeight(),oBrw:nMarqueeStyle:= MARQSTYLE_HIGHLCELL,oBrw:aCols[ 1 ]:EDIT())
RETURN NIL
regards,
A.S.K