Edit and Display formatting request - edit - client scrapped this specs

This Q&A forum allows users to post and respond to "How Do I Do ....." questions. Please do not use to report (suspected) errors - you must use your regional help desk for this. The information contained in this forum has not been validated by LANSA and, as such, LANSA cannot guarantee the accuracy of the information.
Post Reply
UrriahAguilera
Posts: 9
Joined: Wed Feb 08, 2017 3:20 pm

Edit and Display formatting request - edit - client scrapped this specs

Post by UrriahAguilera »

edit - client scrapped this specs

Greetings everyone, i hope everyone is doing well.

the customer wants a numeric field to look something like this when in display (top) and while editing (bottom)

Image

when being displayed it should show comma and decimal point (pretty much looks like Edit Code 1 or 2). BUT, when being edited, the comma and decimal shouldnt be visible, basically looking like a whole number. the value will always be divided by 100 thus if the user types 400 like in the snippet, that means the value is 4.00. 400000 will be 4,000.00, 123 will be 1.23. so on and so forth

i was wondering if anyone has did something similar in Lansa that i can replicate. the issue basically stems from the web page being hard to edit while in a mobile device.

so the requirements for this issue are
  • Display should be identical to an edit code 1 or 2
  • While editing, no commas and decimals should be visible. basically it should look like a whole number
  • a numeric field, the numeric keyboard should load upon the gotfocus event
thanks everyone, i truly appreciate all replies
Last edited by UrriahAguilera on Tue Apr 21, 2020 12:03 pm, edited 1 time in total.
atostaine
Posts: 696
Joined: Wed Jan 20, 2016 7:38 am

Re: Edit and Display formatting request

Post by atostaine »

I would make the edit field have zero decimals, editcode Z. Then just divide it and put it in the display field. You can use the keypress event to keep them in sync.
Art Tostaine
UrriahAguilera
Posts: 9
Joined: Wed Feb 08, 2017 3:20 pm

Re: Edit and Display formatting request

Post by UrriahAguilera »

Thanks Art,

i used your suggestion and came up with this, basically this RP has 2 fields. the display is formatted and visible when the edit isnt and vice versa. clicking the display will send you to the edit field (edit code Z) and should enable you to edit without decimals. upon leaving the edit field, the display field should be visible with the formatted value of the edit field.

Code: Select all

Function Options(*DIRECT)
Begin_Com Role(*EXTENDS #PRIM_PANL) Displayposition(1) Left(0) Tabposition(1) Top(0) Width(220) Height(30) Layoutmanager(#Layout) 

Define_Com Class(#PRIM_TBLO) Name(#Layout)
Define_Com Class(#PRIM_TBLO.Column) Name(#LayoutColumn1) Displayposition(1) Parent(#Layout)
Define_Com Class(#PRIM_TBLO.Row) Name(#LayoutRow1) Displayposition(1) Parent(#Layout)
Define_Com Class(#PRIM_TBLO.Item) Name(#LayoutItem1) Alignment(TopLeft) Column(#LayoutColumn1) Manage(#zz_Edit) Parent(#Layout) Row(#LayoutRow1) Flow(Down)
Define_Com Class(#PRIM_TBLO.Item) Name(#LayoutItem2) Alignment(TopLeft) Column(#LayoutColumn1) Manage(#zz_Display) Parent(#Layout) Row(#LayoutRow1) Flow(Down)

Define_Com Class(#STD_PRICE.EditField) Name(#zz_Display) Displayposition(1) Left(0) Parent(#COM_OWNER) Tabposition(1) Top(0) Helperposition(None) Captionposition(None) Height(30) Appearance(EditBox) Width(220) Themedrawstyle('Strong') Editalignment(Right)
Define_Com Class(#STD_COUNT.EditField) Name(#zz_Edit) Displayposition(2) Left(0) Parent(#COM_OWNER) Tabposition(2) Top(30) Helperposition(None) Captionposition(None) Height(30) Appearance(EditBox) Width(220) Themedrawstyle('Strong') Editalignment(Right)


Override Field(#STD_COUNT) Length(11) Edit_Code(Z)
Override Field(#STD_PRICE) Length(11) Decimals(2) Edit_Code(4)

Define_Pty Name(uValue) Get(*AUTO #zz_Display) Set(*AUTO #zz_Display)
 
Mthroutine Name(umInitialize)
#zz_Display.Visible := True
#zz_Edit.Visible := False
Endroutine


Evtroutine Handling(#zz_Display.GotFocus)
#zz_Edit.Visible := True
#zz_Display.Visible := False

#zz_Edit := (#zz_Display * 100)

#zz_Edit.SetFocus
Endroutine

Evtroutine Handling(#zz_Edit.LostFocus)
#zz_Display.Visible := True
#zz_Edit.Visible := False

If Cond(#zz_Edit <> 0)
#zz_Display := (#zz_Edit / 100)
Endif
Endroutine
End_Com
but this solution seems to have a couple of issues
  • it needs another click on the edit field to bring up the cursor.
  • lostfocus event is a little unstable. leaving via tab or clicking other fields doesnt seem to trigger the lostfocus event
the customer wanted this solution as the current way fields are being handled in handheld/mobile device is not as user friendly as they wanted it to be, specially with the decimals. thus the request to just enter the number and divide it by 100 to get the formatted value.
atostaine
Posts: 696
Joined: Wed Jan 20, 2016 7:38 am

Re: Edit and Display formatting request

Post by atostaine »

Try key press event on zz_edit and/or lost focus. You can look for the tab key to be pressed.

I’m not in front of an IDE. I can provide a sample tomorrow (I’m in North America)
Art Tostaine
UrriahAguilera
Posts: 9
Joined: Wed Feb 08, 2017 3:20 pm

Re: Edit and Display formatting request

Post by UrriahAguilera »

update.

i updated the RP and am using properties and events to signal the webpage where im using this when to set the edit/display modes on

Code: Select all

Function Options(*DIRECT)
Begin_Com Role(*EXTENDS #PRIM_PANL) Displayposition(1) Left(0) Tabposition(1) Top(0) Width(220) Height(30) Layoutmanager(#Layout) Tabstop(False)

Define_Com Class(#PRIM_TBLO) Name(#Layout)
Define_Com Class(#PRIM_TBLO.Column) Name(#LayoutColumn1) Displayposition(1) Parent(#Layout)
Define_Com Class(#PRIM_TBLO.Row) Name(#LayoutRow1) Displayposition(1) Parent(#Layout)
Define_Com Class(#PRIM_TBLO.Item) Name(#LayoutItem1) Alignment(TopLeft) Column(#LayoutColumn1) Manage(#zz_Edit) Parent(#Layout) Row(#LayoutRow1) Flow(Down)
Define_Com Class(#PRIM_TBLO.Item) Name(#LayoutItem2) Alignment(TopLeft) Column(#LayoutColumn1) Manage(#zz_Display) Parent(#Layout) Row(#LayoutRow1) Flow(Down)

Define_Com Class(#CSS_BAMT1.EditField) Name(#zz_Display) Displayposition(1) Left(0) Parent(#COM_OWNER) Tabposition(1) Top(0) Helperposition(None) Captionposition(None) Height(30) Appearance(EditBox) Width(220) Themedrawstyle('Strong') Editalignment(Right) Tabstop(False)
Define_Com Class(#CSS_BAMT2.EditField) Name(#zz_Edit) Displayposition(2) Left(0) Parent(#COM_OWNER) Tabposition(2) Top(30) Helperposition(None) Captionposition(None) Height(30) Appearance(EditBox) Width(220) Themedrawstyle('Strong') Editalignment(Right)


Override Field(#CSS_BAMT2) Length(11) Edit_Code(Z)
Override Field(#CSS_BAMT1) Length(11) Decimals(2) Edit_Code(4)

Define_Pty Name(uValue) Get(*AUTO #zz_Display) Set(*AUTO #zz_Display)
Define_Pty Name(uDisplay) Set(SetDisplay)

Define_Evt Name(ueDisplayGotFocus)
Define_Evt Name(ueEditLostFocus)


Evtroutine Handling(#zz_Display.GotFocus)
Signal Event(ueDisplayGotFocus)

#zz_Edit := (#zz_Display * 100)
Endroutine


Evtroutine Handling(#zz_Edit.LostFocus)
If Cond(#zz_Edit <> 0)
#zz_Display := (#zz_Edit / 100)
Endif

Signal Event(ueEditLostFocus)
Endroutine


Ptyroutine Name(SetDisplay)
Define_Map For(*INPUT) Class(#PRIM_BOLN) Name(#iDisplay)

* One of these fields must be visible at all times
#zz_Display.Visible := #iDisplay
#zz_Edit.Visible := *Not #iDisplay

If Cond(*Not #iDisplay)
#zz_Edit.SetFocus
Endif
Endroutine
End_Com

then on the webpage that uses this RP, i am setting the display/edit mode based on the signal events i got. when one RP is edit, the others are on display. pretty simple so far

Code: Select all

Evtroutine Handling(#COM_OWNER.Initialize)
#rp_1.uValue := 40000
#rp_2.uValue := 4000
#rp_3.uValue := 40.01

Set Com(#RP_1 #RP_2 #RP_3) Udisplay(True)
Endroutine
Evtroutine Handling(#RP_1.ueDisplayGotFocus)
Set Com(#RP_2 #RP_3) Udisplay(True)
Set Com(#RP_1) Udisplay(False)
Endroutine
Evtroutine Handling(#RP_2.ueDisplayGotFocus)
Set Com(#RP_1 #RP_3) Udisplay(True)
Set Com(#RP_2) Udisplay(False)
Endroutine
Evtroutine Handling(#RP_3.ueDisplayGotFocus)
Set Com(#RP_1 #RP_2) Udisplay(True)
Set Com(#RP_3) Udisplay(False)
but the cursor is on the fickle side. sometimes i only need one click to have it in the selected field, a lot of times i need to click twice. i would love to hear what i need to do to improve this
UrriahAguilera
Posts: 9
Joined: Wed Feb 08, 2017 3:20 pm

Re: Edit and Display formatting request

Post by UrriahAguilera »

Update - client scrapped the specs. thanks for the input @atostaine
Post Reply