How do I know which cell I changed in the ItemChanged Event

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
dhnaigles
Posts: 43
Joined: Wed Feb 03, 2016 1:34 am
Location: Marlborough, MA, USA

How do I know which cell I changed in the ItemChanged Event

Post by dhnaigles » Fri Aug 26, 2016 6:49 am

I have 2 columns of a grid (WIN) that are ReadOnly(False). How do I know which of those columns were changed when the ItemChanged event or ItemChangedAccept event has triggered? I need to do 2 different things depending upon the column that is changed. Thanks in advance.

User avatar
Stewart Marshall
Posts: 417
Joined: Thu Nov 05, 2015 5:25 pm

Re: How do I know which cell I changed in the ItemChanged Event

Post by Stewart Marshall » Mon Aug 29, 2016 9:24 am

Hi David

The Grid FocusCell property (http://docs.lansa.com/14/EN/LANSA016/PR ... usCell.htm) provides access to the active cell.

The alternative, and my preferred method of processing specific cell changes, is to use the EditorChanged event (http://docs.lansa.com/14/EN/LANSA016/PR ... hanged.htm)

This is fired for every key stroke.

Code: Select all

Function Options(*DIRECT)
Begin_Com Role(*EXTENDS #PRIM_FORM) ClientWidth(1098) ClientHeight(398) ComponentVersion(2) Top(198) Left(114) LayoutManager(#Layout1) Theme(#SYS_THEME<2015Gray>)

Define_Com Class(#PRIM_TBLO) Name(#Layout1)
Define_Com Class(#PRIM_TBLO.Column) Name(#Column1) DisplayPosition(1) Parent(#Layout1) Width(1.21)
Define_Com Class(#PRIM_TBLO.Column) Name(#Column2) DisplayPosition(2) Parent(#Layout1) Width(0.79)
Define_Com Class(#PRIM_TBLO.Row) Name(#Row1) DisplayPosition(1) Parent(#Layout1)
Define_Com Class(#PRIM_TBLO.Item) Name(#LayoutItem1) Column(#Column1) Manage(#Grid) Parent(#Layout1) Row(#Row1) MarginBottom(2) MarginLeft(2) MarginRight(2) MarginTop(2)
Define_Com Class(#PRIM_TBLO.Item) Name(#LayoutItem2) Alignment(TopLeft) Column(#Column2) Manage(#Column) Parent(#Layout1) Row(#Row1) Sizing(FitToWidth) Flow(Down) MarginLeft(2) MarginTop(2)
Define_Com Class(#PRIM_TBLO.Item) Name(#LayoutItem3) Alignment(TopLeft) Column(#Column2) Manage(#Row) Parent(#Layout1) Row(#Row1) Sizing(FitToWidth) Flow(Down) MarginLeft(2) MarginTop(2)
Define_Com Class(#PRIM_TBLO.Item) Name(#LayoutItem4) Alignment(TopLeft) Column(#Column2) Manage(#NewValue) Parent(#Layout1) Row(#Row1) Sizing(FitToWidth) Flow(Down) MarginLeft(2) MarginTop(2)

Define_Com Class(#PRIM_GRID) Name(#Grid) CaptionNoBlankLines(True) ColumnScroll(False) ComponentVersion(1) DisplayPosition(1) Left(2) Parent(#COM_OWNER) ShowSelection(True) ShowSelectionHilight(False) ShowSortArrow(True) TabPosition(1) Top(2) Height(394) Width(661) ColumnButtonHeight(25) RowHeight(25)
Define_Com Class(#PRIM_GDCL) Name(#GridColumn1) DisplayPosition(1) Parent(#Grid) Source(#xDemoNumber) ReadOnly(False) Width(23)
Define_Com Class(#PRIM_GDCL) Name(#GridColumn2) DisplayPosition(2) Parent(#Grid) Source(#xDemoAlpha128) Width(58) ReadOnly(False)
Define_Com Class(#PRIM_LABL) Name(#Column) Caption('Column') DisplayPosition(2) Ellipses(Word) Height(25) Left(667) Parent(#COM_OWNER) TabPosition(2) TabStop(False) Top(2) VerticalAlignment(Center) Width(431) ThemeDrawStyle('MediumTitle') MarginLeft(2)
Define_Com Class(#PRIM_LABL) Name(#Row) Caption('Row') DisplayPosition(3) Ellipses(Word) Height(25) Left(667) Parent(#COM_OWNER) TabPosition(3) TabStop(False) Top(29) VerticalAlignment(Center) Width(431) ThemeDrawStyle('MediumTitle') MarginLeft(2)
Define_Com Class(#PRIM_LABL) Name(#NewValue) Caption('NewValue') DisplayPosition(4) Ellipses(Word) Height(25) Left(667) Parent(#COM_OWNER) TabPosition(4) TabStop(False) Top(56) VerticalAlignment(Center) Width(431) ThemeDrawStyle('MediumTitle') MarginLeft(2)

Evtroutine Handling(#Com_Owner.CreateInstance)

Inz_List Named(#Grid) Num_Entrys(10)

Endroutine

Evtroutine Handling(#Grid.EditorChanged) Value(#Value)

#Column := ("Column - &1").Substitute( #Grid.FocusCell.Column.Name )
#Row := ("Row - &1").Substitute( #Grid.CurrentItem.Entry.AsString )
#NewValue := ("Value - &1").Substitute( #Value )

Endroutine

End_Com
Regards
Stewart Marshall

Independent IT Consultant
www.marshallfloyd.com.au

dhnaigles
Posts: 43
Joined: Wed Feb 03, 2016 1:34 am
Location: Marlborough, MA, USA

Re: How do I know which cell I changed in the ItemChanged Event

Post by dhnaigles » Wed Aug 31, 2016 9:24 pm

Thank you, Stewart. As always, you provide fantastic solutions.

Post Reply