#PRIM_MD.List Row Background Colour

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
jimwatterson
Posts: 56
Joined: Thu Jul 09, 2020 8:31 am

#PRIM_MD.List Row Background Colour

Post by jimwatterson »

I have a #PRIM_MD.List and I wish to highlight certain lines

With a #PRIM_LIST I can use

#List.CurrentItem.ThemeDrawStyle := 'LightError'

#PRIM_MD.List doesn't have this property.

I've tried

Add_Entry To_List(#List1)
#List1.CurrentItem.RelatedReference <= #s
#List1.CurrentItem.Style.BackgroundBrush <= #AltBrush

But this crashes at run time with an error that says #List1.CurrentItem.Style.BackgroundBrush is null.

Any ideas anyone?

Cheers
Jim
BrendanB
Posts: 134
Joined: Tue Nov 24, 2015 10:29 am

Re: #PRIM_MD.List Row Background Colour

Post by BrendanB »

Jim,

you could 'cheat' a little...
place a Panel (sized FitBoth) on the list entry (Send to Back).
Then set the color:
#BackPanel.CurrentItem.Style <= #BackgroundStyle
or
#BackPanel.CurrentItem.ThemeDrawStyle <= #AlternateColor

since a #PRIM_MD.List is a compound control, you can have as many items as you want, so this would likely give the result.
jimwatterson
Posts: 56
Joined: Thu Jul 09, 2020 8:31 am

Re: #PRIM_MD.List Row Background Colour

Post by jimwatterson »

Thanks Brendan. I might give that a go later. It doesn't seem an unreasonable requirement.
kno_dk
Posts: 219
Joined: Tue Feb 23, 2016 12:00 am

Re: #PRIM_MD.List Row Background Colour

Post by kno_dk »

Hi

I am trying this way to change the background color. But I am not able to put/drag a panel on the list (#PRIM_MD.LIst).

is it just me or is it the way it is?

I am on LANSA V15 EPC150060
BrendanB
Posts: 134
Joined: Tue Nov 24, 2015 10:29 am

Re: #PRIM_MD.List Row Background Colour

Post by BrendanB »

Hi,

I just tried the following at EPC150060

This is a view -- you can show it on a webpage to see the effect (you should get 50 items with alternate background colors.

Whilst i can see that you no longer get to drag a panel onto an #PRIM_MD.List, you can also acheive this using a #PRIM_MD.ListLabel (ie. a text label dragged onto the list) -- just set it to be FitBoth, Send it to Back, set the caption to blank and it will show behind everything... but that was a temporary *workaround* for when it wasnt allowing us to set a background brush.

Code: Select all

Begin_Com Role(*EXTENDS #PRIM_VIEW) DisplayPosition(1) TabPosition(1) LayoutManager(#PageLayout)

Define_Com Class(#Prim_vs.Style) Name(#MainRow) BackgroundBrush(#Brush1)
Define_Com Class(#PRIM_VS.SolidBrush) Name(#Brush1) Color(248:187:208)

Define_Com Class(#Prim_vs.Style) Name(#AltRow) BackgroundBrush(#Brush2)
Define_Com Class(#PRIM_VS.SolidBrush) Name(#Brush2) Color(197:202:233)

Define_Com Class(#PRIM_TBLO) Name(#PageLayout)
Define_Com Class(#PRIM_TBLO.Row) Name(#Layout1Row1) DisplayPosition(1) Parent(#PageLayout)
Define_Com Class(#PRIM_TBLO.Column) Name(#Layout1Column1) DisplayPosition(1) Parent(#PageLayout)
Define_Com Class(#PRIM_TBLO.Item) Name(#Layout1Item1) Alignment(TopLeft) Column(#Layout1Column1) Manage(#List) Parent(#PageLayout) Row(#Layout1Row1)

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(CenterLeft) Column(#LayoutListColumn1) Flow(CenterVertical) Manage(#ListPrimaryText) MarginLeft(16) MarginRight(16) Parent(#LayoutList) Row(#LayoutListRow1) Sizing(ContentHeightFitToWidth)
Define_Com Class(#PRIM_TBLO.Item) Name(#LayoutListItem2) Alignment(CenterLeft) Column(#LayoutListColumn1) Flow(CenterVertical) Manage(#ListSecondaryText) MarginLeft(16) MarginRight(16) Parent(#LayoutList) Row(#LayoutListRow1) Sizing(ContentHeightFitToWidth)

Define_Com Class(#PRIM_MD.List) Name(#List) DisplayPosition(1) LayoutManager(#LayoutList) Left(0) Parent(#COM_OWNER) RowHeight(72) TabPosition(1) ThemeDrawStyle('Card') Top(0) Height(450) Width(300) ItemMarginBottom(4) ItemThemeDrawStyle('Card')
Define_Com Class(#PRIM_MD.ListLabel) Name(#ListPrimaryText) Caption('Two line item') DisplayPosition(1) Height(24) Left(16) Parent(#List) TabPosition(1) ThemeDrawStyle('Heading3') Top(12) Width(266)
Define_Com Class(#PRIM_MD.ListLabel) Name(#ListSecondaryText) Caption('Secondary Text') DisplayPosition(3) Height(24) Left(16) Parent(#List) TabPosition(3) ThemeDrawStyle('ForegroundSecondary') Top(36) Width(266)

Evtroutine Handling(#COM_OWNER.Prepare)

#COM_OWNER.PrepList

Endroutine

Mthroutine Name(PrepList)

Inz_List Named(#List) Num_Entrys(50)

For Each(#Entry) In(#List.Items)

If (#Entry.Entry.Mod( 2 ) = 0)

#Entry.Style <= #AltRow

Else

#Entry.Style <= #MainRow

Endif

Endfor

* Or could use
* Begin_Loop Using(#std_num) To(50)
*
* Add_Entry To_List(#List)
*
* If (#std_num.Mod( 2 ) = 0)
*
* #List.CurrentItem.Style <= #AltRow
*
* Else
*
* #List.CurrentItem.Style <= #MainRow
*
* Endif
*
* End_Loop

Endroutine

End_Com

kno_dk
Posts: 219
Joined: Tue Feb 23, 2016 12:00 am

Re: #PRIM_MD.List Row Background Colour

Post by kno_dk »

HI.

I use #List.CurrentItem.Style <= #MainRow

and it works.

thanks.
Post Reply