How to add column in layout dynamically

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
ajr
Posts: 10
Joined: Wed Aug 22, 2018 9:35 am

How to add column in layout dynamically

Post by ajr »

Using a keyed collection of #PRIM_TBLO.Column, how do I add column in layout dynamically?
Currently, I am using the code below

* definition of collection of columns
Define_Com Class(#PRIM_KCOL<#PRIM_TBLO.Column #STD_DESCL>) Name(#uCols) Desc('Collection of columns') Style(Collection)

* create column and add it to the collection
Define Field(#L_COLNAME) Reffld(#STD_DESC)
Define_Com Class(#PRIM_TBLO.Column) Name(#L_ColReference) Reference(*DYNAMIC)
#L_COLNAME := 'Layout1Column' + (#uCols.ItemCount + 1).asstring
Set_Ref Com(#uCols<#L_COLNAME>) To(*CREATE_FROM #L_COLNAME)
#L_ColReference <= #uCols<#L_COLNAME>

* attach column to the view's #PRIM_TBLO called #Layout
Set Com(#L_ColReference) Parent(#Layout)

But this code gives me the error: Failed to load /lansav142/cml/layout1column1.js?v=825400672
ajr
Posts: 10
Joined: Wed Aug 22, 2018 9:35 am

Re: How to add column in layout dynamically

Post by ajr »

Solved.

I was creating the new instance of a column incorrectly.
Below is the correct code.

* create a new instance of the named column
Set_Ref Com(#uCols<#W_LCOLNAM>) To(*CREATE_AS #PRIM_TBLO.Column)
#uCols<#W_LCOLNAM> <= *New #PRIM_TBLO.Column
Post Reply