Page 1 of 1
Edit and Display formatting request - edit - client scrapped this specs
Posted: Fri Apr 03, 2020 6:51 pm
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)
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
Re: Edit and Display formatting request
Posted: Sat Apr 04, 2020 2:26 am
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.
Re: Edit and Display formatting request
Posted: Wed Apr 08, 2020 12:15 pm
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.
Re: Edit and Display formatting request
Posted: Wed Apr 08, 2020 12:23 pm
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)
Re: Edit and Display formatting request
Posted: Tue Apr 14, 2020 12:22 pm
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
Re: Edit and Display formatting request
Posted: Tue Apr 21, 2020 12:02 pm
by UrriahAguilera
Update - client scrapped the specs. thanks for the input @atostaine