Cool that you are making such good use of the SDK!
You have run into a limitation that we have not solved yet. There is a workaround. I'll share it with you but only if you don't tell anyone else :-)
Let me first explain the funny model of layouts "calling" pages. We see a layout as a "function" where the placeholders can be seen as parameters. A page "calls" the layout and the outermost widgets on a page are passed as arguments to the layout. A layout call argument tells you where to place what widget. The code below creates a layout argument for a given placeholder name. Afterwards you still need to set the widget property.
Good luck!
export function createLayoutArgument(layoutCall: pages.LayoutCall, name: string) {
const result = pages.LayoutCallArgument.createIn(layoutCall);
(result as any)["__parameter"].updateWithRawValue(layoutCall.layoutQualifiedName + "." + name);
return result;
}
Update: I updated the code so that it also works if you pass the no-implicit-any compiler flag to the Typescript compiler.
I did it, it works but... When one create a new app must use "parameterName" not "parameter" because somehow the new app is created using Mendix v 6.0.0. Also when I create new LayoutGridRow or LayoutGrid, there is always one element added, but not by me. So I have to perform "clear()" on the array before pushing elements inside. I've checked the array and there is one element after initialization always by default. Also the text on the widgets is not shown instead the text is "Empty caption" doesn't matter will I create new app or update existing one?
How do you use the "createLayoutArgument" function? We've tried different values but we end up with "value cannot be null" exception.