Word wrapping in Lists

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

Word wrapping in Lists

Post by soa »

I'm writing a web application that will replace a hrml web app and it contains a number of tables many of which contain cell data that is too wide to fit in the allowed space. The standard html behavior is to wrap this text. I cannot reproduce this behavior using a standard Lansa list. Is it possible?

I have received advice that I can probably do this using a reusable part in a cell which I will investigate but this seems to me to be such an obvious requirement that it should be supported as standard.

In a related matter in my table I have to display user entered instructions which can include html markup. Again this is not an issue in a html table but the list displays the mark up as is. Again, I'm sure I could get round this with a re-usable part that implements a html control but again it would be nice to have a standard component.
User avatar
Stewart Marshall
Posts: 417
Joined: Thu Nov 05, 2015 5:25 pm

Re: Word wrapping in Lists

Post by Stewart Marshall »

Word wrapping in list has been under consideration for some time, but it requires changes to edit and fields. This means that while it's a seemingly simple addition, the repercussions are many. There was also a prerequisite for the work which was the variable sizing features that were delivered in SP1. Without these, we could have wrapped the text, but the list item height would have remained unchanged. The good news is that it's on the list for SP2.

In the meantime, you'll need to use a reusable part that contains a label. The layout for the part needs to be defined as ContentHeight so that it resizes based on the content of the label it's showing. The label in turn is also defined as fitting to the available width and using the content height.

Finally, the list itself needs a RowSize of 0 and RowSizing for the list itself need to be individual so that rows can be different heights. If you specify a RowHeight the list will assume you know what you're doing and make the rows that height.


Embedding a part in a list cell is perhaps a little overkill for your simple requirement, but it means that can make whatever you want with as complex a layout and behaviour as you like. This then will let you embed HTML in the middle of a cell. LANSA can't allow markup to be rendered directly within the UI because of the potential impact on our runtime, so you're forced to use the HTML component wrapper.

I've attached a simple example demonstrating the list and page content sizing technique.
Untitled.png
Untitled.png (45.64 KiB) Viewed 17308 times
Regards
Attachments
ExpandingListCell.zip
(10.77 KiB) Downloaded 1321 times
Stewart Marshall

Independent IT Consultant
www.marshallfloyd.com.au
soa
Posts: 339
Joined: Mon Dec 07, 2015 3:15 pm

Re: Word wrapping in Lists

Post by soa »

Thanks, All makes sense. I'll give that a go.
soa
Posts: 339
Joined: Mon Dec 07, 2015 3:15 pm

Re: Word wrapping in Lists

Post by soa »

I've modified your example but I have an issue.



The modified part is now

Function Options(*DIRECT)
Begin_Com Role(*EXTENDS #PRIM_PANL *implements #Prim_list.IListCellDesign) Displayposition(1) Left(0) Tabposition(1) Top(0) Width(385) Layoutmanager(#Layout1) Height(112)

Define_Com Class(#PRIM_TBLO) Name(#Layout1) Sizing(ContentHeight)
Define_Com Class(#PRIM_TBLO.Row) Name(#LayoutRow1) Displayposition(1) Parent(#Layout1)
Define_Com Class(#PRIM_TBLO.Column) Name(#LayoutColumn1) Displayposition(1) Parent(#Layout1)
Define_Com Class(#PRIM_TBLO.Item) Name(#LayoutItem1) Column(#LayoutColumn1) Manage(#Label1) Parent(#Layout1) Row(#LayoutRow1) Sizing(ContentHeightFitToWidth) Alignment(TopCenter)

Define_Com Class(#PRIM_LABL) Name(#Label1) Caption('Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.') Displayposition(1) Ellipses(Word) Height(112) Left(0) Parent(#COM_OWNER) Tabposition(1) Tabstop(False) Top(0) Verticalalignment(Center) Width(385) Marginleft(4) Marginbottom(2) Marginright(4) Margintop(2) Themedrawstyle('plaintext')

* Fields mapped in when the entry is added to the list

Group_By Name(#ListFields) Fields(#CellText)

Mthroutine Name(OnAdd) Options(*Redefine)

#sys_web.Console.log( ("CELL=&1").Substitute( #CellText ) )

#Label1.Caption := #celltext

Endroutine

End_Com

and in the part with list I have

#celltext := #CRSEXMTXT

#sys_web.Console.log( ("CELLIN=&1").Substitute( #CellText ) )

Add_Entry To_List(#lstExams)


In the console log I can see there is a value going in but in the OnAdd event the value is blank.

Is there something obvious I'm doing wrong?

(We're getting very close - I can see this will be very powerful).
User avatar
Stewart Marshall
Posts: 417
Joined: Thu Nov 05, 2015 5:25 pm

Re: Word wrapping in Lists

Post by Stewart Marshall »

Yep

You need to specify the fields in the list that the reusable part represents. This is done using *ListFields [#Group_ByName] on the Begin_Com.

Code: Select all

Begin_Com Role(*EXTENDS #PRIM_PANL *implements #Prim_list.IListCellDesign *ListFields #ListFields)
Stewart Marshall

Independent IT Consultant
www.marshallfloyd.com.au
soa
Posts: 339
Joined: Mon Dec 07, 2015 3:15 pm

Re: Word wrapping in Lists

Post by soa »

Stewart

Thanks for that. I've got a label version of this working fine with the content supplied at run time and I've moved to the next step of replacing the label with a html control but I can't get any html content to display.

Using ListContentPart as an base I've built ListContentPartHTML (below) and added it to LIstContent but the column remains blank.

Where am I going wrong?

Function Options(*DIRECT)
Begin_Com Role(*EXTENDS #PRIM_PANL *implements #Prim_list.IListCellDesign) Displayposition(1) Left(0) Tabposition(1) Top(0) Width(385) Layoutmanager(#Layout1)

Define_Com Class(#PRIM_TBLO) Name(#Layout1) Sizing(ContentHeight)
Define_Com Class(#PRIM_TBLO.Row) Name(#LayoutRow1) Displayposition(1) Parent(#Layout1)
Define_Com Class(#PRIM_TBLO.Column) Name(#LayoutColumn1) Displayposition(1) Parent(#Layout1)
Define_Com Class(#PRIM_TBLO.Item) Name(#Html1Item1) Manage(#Html1) Parent(#Layout1) Row(#LayoutRow1) Sizing(ContentHeightFitToWidth) Column(#LayoutColumn1) Alignment(TopCenter)

Define_Com Class(#PRIM_WEB.HtmlContainer) Name(#Html1) Description('Html Container') Displayposition(1) Height(16) Parent(#COM_OWNER) Tabposition(1) Tabstop(False) Width(385) Html('This is a <strong>HTML</strong> Fragment')


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

Re: Word wrapping in Lists

Post by Stewart Marshall »

Hi Jim

There are a couple of things going on here.

The first is that there appears to be a bug. It seems that an HTML container isn't rendered in a list cell if it's the only control. A simple work around for this would be to add a label with no text.

The second is that the HTML Container makes a DIV at run time. This is a problem for content sizing as there's no way that we can determine what's in it. This means we can't resize the control and subsequently, we can't resize the list item.

However, you might be able to get somewhere close to solving the issue by using an HTML control and a label with transparent text. Set the HTML control to FitBoth and the label to ContentHeightFitToWidth, then populate both with the HTML. As the HTML will likely contain more text than is actually seen, the Label will always be bigger than the required HTML.

Code: Select all

Begin_Com Role(*EXTENDS #PRIM_PANL *implements #Prim_list.IListCellDesign *listFields #ListFields) Displayposition(1) Left(0) Tabposition(1) Top(0) Width(385) Layoutmanager(#Layout1)

Define_Com Class(#PRIM_VS.Style) Name(#Style1) Foregroundbrush(#Brush1)
Define_Com Class(#PRIM_VS.SolidBrush) Name(#Brush1) Color(Transparent)

Define_Com Class(#PRIM_TBLO) Name(#Layout1) Sizing(ContentHeight)
Define_Com Class(#PRIM_TBLO.Row) Name(#LayoutRow1) Displayposition(1) Parent(#Layout1)
Define_Com Class(#PRIM_TBLO.Column) Name(#LayoutColumn1) Displayposition(1) Parent(#Layout1)
Define_Com Class(#PRIM_TBLO.Item) Name(#Html1Item1) Manage(#Html) Parent(#Layout1) Row(#LayoutRow1) Column(#LayoutColumn1) Alignment(TopCenter)
Define_Com Class(#PRIM_TBLO.Item) Name(#LayoutItem1) Column(#LayoutColumn1) Manage(#Label) Parent(#Layout1) Row(#LayoutRow1) Sizing(ContentHeightFitToWidth) Alignment(TopCenter)

Group_By Name(#ListFields) Fields(#YourHTMLField)

Define_Com Class(#PRIM_WEB.HtmlContainer) Name(#Html) Description('Html Container') Displayposition(2) Height(50) Parent(#COM_OWNER) Tabposition(1) Tabstop(False) Width(385)
Define_Com Class(#PRIM_LABL) Name(#Label) Caption('Label') Displayposition(1) Ellipses(Word) Height(17) Left(0) Parent(#COM_OWNER) Tabposition(2) Tabstop(False) Top(0) Verticalalignment(Center) Width(385) Style(#Style1)

Mthroutine Name(OnAdd) Options(*Redefine)

#Html #Label := #YourHTMLField

Endroutine

End_Com
Stewart Marshall

Independent IT Consultant
www.marshallfloyd.com.au
soa
Posts: 339
Joined: Mon Dec 07, 2015 3:15 pm

Re: Word wrapping in Lists

Post by soa »

Stewart

That worked beautifully. As you said the label/html size is close enough if the mark is reasonable.
soa
Posts: 339
Joined: Mon Dec 07, 2015 3:15 pm

Re: Word wrapping in Lists

Post by soa »

Hi

You mention above that word wrapping in lists is slated for SP2, looking at the documentation I can find no reference. Did it make the cut?
User avatar
Stewart Marshall
Posts: 417
Joined: Thu Nov 05, 2015 5:25 pm

Re: Word wrapping in Lists

Post by Stewart Marshall »

Wordwrap in lists will be delivered as part of SP2. I believe this is scheduled for second quarter 2017.
Stewart Marshall

Independent IT Consultant
www.marshallfloyd.com.au
soa
Posts: 339
Joined: Mon Dec 07, 2015 3:15 pm

Re: Word wrapping in Lists

Post by soa »

My mistake I thought the newly published epc was SP2.
Post Reply