PRIM_MD.Dropdown Changed

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
jyoung
Posts: 652
Joined: Thu Jan 21, 2016 6:43 am
Location: Oklahoma City, OK USA

PRIM_MD.Dropdown Changed

Post by jyoung » Thu Oct 18, 2018 6:36 am

The "Changed" event on most PRIM_MD.* controls gets fired when the USER changes the value of the field. This does not seem to be the case with PRIM_MD.DropDown as the Changed event gets fired when the value is set.

This is causing all kinds of havoc with change detection.

I have a field that uses a PRIM_MD.DropDown visualization with a pick list.

Here is an example field (TestField)

Code: Select all

begin_com role(*EXTENDS #PRIM_OBJT)

begin_com role(*Visual #PRIM_EVEF) name(#VisualEdit) UsePicklist(False) ComponentVersion(1) Height(21) Width(323)

end_com

begin_com role(*picklist) name(#Picklist) NoMatchAction(ShowValue)

define_com class(#PRIM_PKIT) name(#PKIT_1) Value(1) Caption('One') Parent(#Picklist)
define_com class(#PRIM_PKIT) name(#PKIT_2) Value(2) Caption('Two') Parent(#Picklist)

end_com
begin_com role(*Visual #PRIM_MD.DropdownField) name(#DropdownField) DefaultVisual(True)

end_com
end_com
Now, when I set that field in a Server Module

Code: Select all

begin_com role(*EXTENDS #PRIM_SRVM)

group_by name(#DoItFields) fields(#STD_TEXT #TestField)
srvroutine name(DoIt)
group_map for(*OUTPUT) group(#DoItFields)

#STD_TEXT := "This is a test from a server module"
#TestField := "2"
endroutine

end_com
The "Changed" event fires on the client. Here is the full client

Code: Select all

begin_com role(*EXTENDS #PRIM_WEB) Theme(#SYS_THEME<MaterialDesignBlue>)

define_com class(#PRIM_TBLO) name(#LayoutList)
define_com class(#PRIM_TBLO.Column) name(#LayoutListColumn1) DisplayPosition(1) Parent(#LayoutList)
define_com class(#PRIM_TBLO.Row) name(#LayoutListRow1) DisplayPosition(1) Parent(#LayoutList)
define_com class(#PRIM_TBLO.Item) name(#LayoutListItem1) Column(#LayoutListColumn1) Manage(#ListSTD_STRNG1) Parent(#LayoutList) Row(#LayoutListRow1) MarginBottom(5) MarginLeft(5) MarginRight(5) MarginTop(5)

define_com class(#PRIM_MD.RaisedButton) name(#Button) Caption('Do It!') DisplayPosition(1) Left(190) Parent(#COM_OWNER) TabPosition(1) ThemeDrawStyle('MediumTitle') Top(170) Width(179)
define_com class(#PRIM_MD.List) name(#List) DisplayPosition(2) LayoutManager(#LayoutList) Left(547) Parent(#COM_OWNER) RowHeight(48) TabPosition(2) ThemeDrawStyle('Card') Top(168)
define_com class(#PRIM_MD.ListLabel) name(#ListSTD_STRNG1) Caption('Standard string field') DisplayPosition(1) DragStyle(None) Left(5) Parent(#List) Source(#STD_STRNG) TabPosition(1) Top(5) Height(38) Width(268)
define_com class(#TestField.DropdownField) name(#TestField) DisplayPosition(3) Left(184) Parent(#COM_OWNER) TabPosition(3) Top(248)

group_by name(#DoItFields) fields(#STD_TEXT #TestField)

evtroutine handling(#Com_owner.Initialize)


endroutine

evtroutine handling(#Button.Click)
#COM_OWNER.DoTest
endroutine

mthroutine name(DoTest)
define_com class(#TestModule.DoIt) name(#doIt)
#doIt.ExecuteAsync DoItFields(#DoItFields)

evtroutine handling(#doIt.Completed)
#STD_STRNG := "DoIt Completed"
add_entry to_list(#List)
endroutine
endroutine

evtroutine handling(#TestField.Changed)
#STD_STRNG := "Test Field Changed"
add_entry to_list(#List)
endroutine
end_com
As I mentioned this is wrecking havoc on change detection because whereas all the other controls only fire the changed event when the USER changes the field, this is firing the event when the value is bound.

This does not seem to be true. https://docs.lansa.com/14/en/lansa016/p ... hanged.htm

Attached is an export demonstrating the behavior.

My question then, is how do I detect when the user has changed the value of a PRIM_MD.Dropdown?
Attachments
QuickExport20181017143519.zip
(10.21 KiB) Downloaded 66 times

jyoung
Posts: 652
Joined: Thu Jan 21, 2016 6:43 am
Location: Oklahoma City, OK USA

Re: PRIM_MD.Dropdown Changed

Post by jyoung » Thu Dec 20, 2018 4:20 am

Just got bit by this again.

I created a support ticket for this back on 10/18 and it was replicated and it was "Accepted as Correction"

A workaround is to check if the dropdown has focus in the changed event.

Code: Select all

Evtroutine Handling(#TestField.Changed)

If (#TestField.Focus)
#STD_STRNG := "Test Field Changed"

Endif
Endroutine
No word on when an update will be available.

Joe

dannyoorburg
Posts: 156
Joined: Mon Jan 04, 2016 9:50 am
Location: Australia

Re: PRIM_MD.Dropdown Changed

Post by dannyoorburg » Fri Dec 21, 2018 4:30 pm

Hi Joe,

I thought it was fixed.

https://www.lansa.com/support/notes/epc/epc142030.htm

mentions

0160963 PRIM_MD.Dropdown changed event fired even when set programmatically
This defect has now been rectified

is that yours?

Cheers,
Danny

jyoung
Posts: 652
Joined: Thu Jan 21, 2016 6:43 am
Location: Oklahoma City, OK USA

Re: PRIM_MD.Dropdown Changed

Post by jyoung » Sat Dec 22, 2018 1:17 am

Could be.

I have 142030 installed and the Changed event kept firing.

Will do some further digging.

Thanks,
Joe

Post Reply