How do I get the displayed value in a cell in a grid instead of the actual value?
Context:
I'm building a dynamic grid filter that should be functional as a reusable part.
I get list of column names in the grid and put them in a combo box.
Everything was working pretty well until I started to use picklists.
The comparison is using the value in the cell, not the display value.
This results in the user having to search for a single letter in some cases when the cell displays something else, which is counterintuitive.
Example:
In Excel something like this would work, but I can't find a LANSA equivalent.
Range("A1").Text instead of Range("A1").Value
Display Value of Cell in Grid
Re: Display Value of Cell in Grid
Hi
Can you post a simplified example of what you are trying to do?
Can you post a simplified example of what you are trying to do?
Re: Display Value of Cell in Grid
DEFINE_COM class(#PRIM_GDCL) name(#GDCL_59) Displayposition(30) Parent(#GRID_1) Source(#STD_NUM) Captiontype(Caption) Caption('Last Receipt')
selectlist named(#GRID_1)
USE builtin(MESSAGE_BOX_SHOW) with_args(OK OK INFORMATION 'Information' #GRID_1.CurrentItem.Cell<>.Value)
* ^ Displays 10
USE builtin(MESSAGE_BOX_SHOW) with_args(OK OK INFORMATION 'Information' #GRID_1.CurrentItem.Cell<>.Text)
* ^ Displays 10.0
endselect
* The value in the cell is 10, but it is displayed as 10.0.
* I want how it is displayed.
selectlist named(#GRID_1)
USE builtin(MESSAGE_BOX_SHOW) with_args(OK OK INFORMATION 'Information' #GRID_1.CurrentItem.Cell<>.Value)
* ^ Displays 10
USE builtin(MESSAGE_BOX_SHOW) with_args(OK OK INFORMATION 'Information' #GRID_1.CurrentItem.Cell<>.Text)
* ^ Displays 10.0
endselect
* The value in the cell is 10, but it is displayed as 10.0.
* I want how it is displayed.
Re: Display Value of Cell in Grid
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
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:
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...
full example here of this test here:
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
Code: Select all
#Grid_1.CurrentItem.Cell<1>.ValueCode: Select all
#Grid_1.CurrentItem.Cell<1>.Column.Source.NameCode: Select all
#STD_AMNT := #Grid_1.CurrentItem.Cell<1>.Value
#STD_STRNG := #STD_AMNT.AsDisplayString( ("EditCode_" + #STD_AMNT.FieldAttributeAsString( EditCode )) )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) )
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
Re: Display Value of Cell in Grid
Wow. This is a lot more complex than I was hoping for, but I can incorporate it into a built-in to make things easier.
Thanks for your help.
Thanks for your help.