Accessing MD List field values

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
soa
Posts: 339
Joined: Mon Dec 07, 2015 3:15 pm

Accessing MD List field values

Post by soa »

I'm iterating through the items in a MD List -see below

I want to set the drawstyle based on the list content but I don't know how to extract the value

For Each(#l) In(#List.Items)
#wrk9n0 += 1

If Cond(#wrk9n0.Mod( 2 ) = 0)
#l.ThemeDrawStyle := 'AlternateItem'
Else
#l.ThemeDrawStyle := ''
Endif

Endfor

I can prompt to

#l.Items<#columnSTDID1>.

But the error says 'Expression #columnSTDID1 does not contain default property'

I'm guessing I have to cast it as something but I don't know what.
jyoung
Posts: 694
Joined: Thu Jan 21, 2016 6:43 am
Location: Oklahoma City, OK USA

Re: Accessing MD List field values

Post by jyoung »

Are you binding your list entries to a field?

If so, you can use #l.Entry to get the entry number.

Code: Select all

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

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) Alignment(TopLeft) Column(#LayoutListColumn1) Manage(#ListSTD_INT1) Parent(#LayoutList) Row(#LayoutListRow1)

define_com class(#PRIM_MD.List) name(#List) DisplayPosition(1) LayoutManager(#LayoutList) Left(435) Parent(#COM_OWNER) RowHeight(48) TabPosition(1) ThemeDrawStyle('Card') Top(123)
define_com class(#PRIM_MD.ListLabel) name(#ListSTD_INT1) Caption('Standard Integer field') DisplayPosition(1) DragStyle(None) Left(0) Parent(#List) Source(#STD_INT) TabPosition(1) Top(0) Height(48) Width(278)
define_com class(#PRIM_MD.RaisedButton) name(#Button) Caption('BUTTON') DisplayPosition(2) Left(236) Parent(#COM_OWNER) TabPosition(2) ThemeDrawStyle('MediumTitle') Top(278)

evtroutine handling(#Com_owner.Initialize)
define_com class(#PRIM_NMBR) name(#lIndex)

#lIndex := 1

dountil (#lIndex > 10)
#STD_INT := #lIndex
add_entry to_list(#List)
#lIndex += 1
enduntil
endroutine

mthroutine name(IterateList)
for each(#lItem) in(#List.Items)
get_entry number(#lItem.Entry)
#SYS_WEB.Console.Log( #STD_INT.AsString )
endfor
endroutine

evtroutine handling(#Button.Click)
#COM_OWNER.IterateList
endroutine
end_com
The only other way I know of is to use the CurrentItem of the PRIM_MD.List* control

Code: Select all

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

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) Alignment(TopLeft) Column(#LayoutListColumn1) Parent(#LayoutList) Row(#LayoutListRow1)

define_com class(#PRIM_MD.List) name(#List) DisplayPosition(1) LayoutManager(#LayoutList) Left(435) Parent(#COM_OWNER) TabPosition(1) ThemeDrawStyle('Card') Top(123)
define_com class(#PRIM_MD.ListEdit) name(#Edit) Caption('Caption') DisplayPosition(1) DragStyle(None) Left(0) Parent(#List) TabPosition(1) Top(0) Width(278)
define_com class(#PRIM_MD.RaisedButton) name(#Button) Caption('BUTTON') DisplayPosition(2) Left(236) Parent(#COM_OWNER) TabPosition(2) ThemeDrawStyle('MediumTitle') Top(278)


evtroutine handling(#Com_owner.Initialize)
define_com class(#PRIM_NMBR) name(#lIndex)

#lIndex := 1

dountil (#lIndex > 10)
add_entry to_list(#List)
#Edit.CurrentItem.Value := #lIndex.AsString
#lIndex += 1
enduntil
endroutine

mthroutine name(IterateList)
for each(#lItem) in(#List.Items)
get_entry number(#lItem.Entry) from_list(#List)
#SYS_WEB.Console.Log( #Edit.CurrentItem.Value )
endfor
endroutine

evtroutine handling(#Button.Click)
#COM_OWNER.IterateList
endroutine
end_com
Joe
soa
Posts: 339
Joined: Mon Dec 07, 2015 3:15 pm

Re: Accessing MD List field values

Post by soa »

Thank you

get_entry number(#lItem.Entry)

was exactly what I was after!

Jim
Post Reply