Hi
In brief, I think the best will be for you to open a case and to request this as an enhancement (for grid component, forms), to maybe add a .text property, or a .asDisplayedValue to receive the formatted response and to avoid doing the same thing twice, meaning once at the grid level to show the field using their editcode, and a second one in your code trying to emulate the same.
I tried with this (full code form below), in which basically, using #STD_AMNT as reference, you can retrieve the value with
you can retrieve the column source name, i.e. the field, using
Code: Select all
#Grid_1.CurrentItem.Cell<1>.Column.Source.Name
but if you want to retrieve the edit code to find the actual presentation, well, you need to move the data first to the actual field to be able to find their editcode using rdmlx intrinsics, which means you will need to need to have a case for each possible field, which most likely defeats the exercise:
Code: Select all
#STD_AMNT := #Grid_1.CurrentItem.Cell<1>.Value
#STD_STRNG := #STD_AMNT.AsDisplayString( ("EditCode_" + #STD_AMNT.FieldAttributeAsString( EditCode )) )
alternatively, you could use the GET_FIELD builtin to retrieve the edit code of anyfield without having to move it to the actual field, but in order to use it sucessfully in a AsDisplayString, you need to have the value first in a field with the same number of decimal places or the result will be different...
Code: Select all
#F03FLD := #Grid_1.CurrentItem.Cell<1>.Column.Source.Name
Use Builtin(GET_FIELD) With_Args(#F03FLD) To_Get(#IO$STS #F03TYP #F03LEN #F03DEC #F03REF #F03DES #F03LBL #F03CH1 #F03OAT #F03IAT #F03EDC)
Define Field(#largenumber) Type(*DEC) Length(15) Decimals(5)
#largenumber := #Grid_1.CurrentItem.Cell<1>.Value
#STD_STRNG := #largenumber.AsDisplayString( ("EditCode_" + #F03EDC) )
full example here of this test here:
Code: Select all
Function Options(*DIRECT)
Begin_Com Role(*EXTENDS #PRIM_FORM) ClientWidth(484) ClientHeight(301) ComponentVersion(2) Left(542) Top(196)
Define_Com Class(#PRIM_GRID) Name(#Grid_1) CaptionNoBlankLines(True) ColumnScroll(False) ComponentVersion(1) DisplayPosition(1) Left(31) Parent(#COM_OWNER) ShowSelection(True) ShowSelectionHilight(False) ShowSortArrow(True) TabPosition(1) Top(22) Height(195) Width(394)
Define_Com Class(#PRIM_GDCL) Name(#GDCL_59) DisplayPosition(1) Parent(#Grid_1) Source(#STD_AMNT) CaptionType(Caption) Caption('Last Receipt')
Evtroutine Handling(#com_owner.CreateInstance)
#STD_AMNT := 31415.926
Inz_List
Use Builtin(MESSAGE_BOX_SHOW) With_Args("OK" "OK" "INFORMATION" 'Information' #Grid_1.CurrentItem.Cell<1>.Value)
* ^ Displays 10
Use Builtin(MESSAGE_BOX_SHOW) With_Args("OK" "OK" "INFORMATION" 'Information' #Grid_1.CurrentItem.Cell<1>.Column.Source.Name)
* ^ Displays 10.0
* Use Builtin(MESSAGE_BOX_SHOW) With_Args("OK" "OK" "INFORMATION" 'Information' #Grid_1.CurrentItem.Cell<1>.Column.Source.Name.FieldAttributeAsString( EditCode ))
#STD_AMNT := #Grid_1.CurrentItem.Cell<1>.Value
Use Builtin(MESSAGE_BOX_SHOW) With_Args("OK" "OK" "INFORMATION" 'Information' #STD_AMNT.FieldAttributeAsString( EditCode ))
* #STD_STRNG := #STD_AMNT.AsDisplayString( EditCode_A )
* Use Builtin(MESSAGE_BOX_SHOW) With_Args("OK" "OK" "INFORMATION" 'Information' #STD_STRNG)
#STD_STRNG := #STD_AMNT.AsDisplayString( ("EditCode_" + #STD_AMNT.FieldAttributeAsString( EditCode )) )
Use Builtin(MESSAGE_BOX_SHOW) With_Args("OK" "OK" "INFORMATION" 'Information' #STD_STRNG)
#F03FLD := #Grid_1.CurrentItem.Cell<1>.Column.Source.Name
Use Builtin(GET_FIELD) With_Args(#F03FLD) To_Get(#IO$STS #F03TYP #F03LEN #F03DEC #F03REF #F03DES #F03LBL #F03CH1 #F03OAT #F03IAT #F03EDC)
Define Field(#largenumber) Type(*DEC) Length(15) Decimals(5)
#largenumber := #Grid_1.CurrentItem.Cell<1>.Value
#STD_STRNG := #largenumber.AsDisplayString( ("EditCode_" + #F03EDC) )
Use Builtin(MESSAGE_BOX_SHOW) With_Args("OK" "OK" "INFORMATION" 'Information' #STD_STRNG)
Endroutine
End_Com