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
How to add column in layout dynamically
Re: How to add column in layout dynamically
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
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