Page 1 of 2

Adding widgets programatically to layout

Posted: Tue May 20, 2014 9:42 am
by mpilo0
Is there a way upon conversion to automatically add widgets to a layout?

Re: Adding widgets programatically to layout

Posted: Wed May 21, 2014 9:55 am
by David
Hi Michael,

This is a bit tricky.

The DDS conversion theme doesn't have a specific property for adding created widgets into a container, it does have scripting hooks where you can provide code that alters the widget properties after the DDS conversion has created them. There is a property in the DDS conversion theme called "add enhancements" that you can assign a function which will be called for each record format. The function is provided a list of all widgets in the record format, and it can make changes to them. There are similar hooks which also allow you to alter any function key links/buttons and grids that are created -- these are handled through separate hooks which work in a similar way to "add enhancements".

As you've probably guessed, adding a widget into a layout is just a matter of setting properties. However, the properties are not visible in the Designer. The way you can see them is to mock up a quick example of what you want (i.e. put a widget into the desired type of layout container) and then select the Local tab from the Save As dialog to download a copy of the display file meta data.

You'll see that the meta data is a list of widgets and their properties. Widgets inside a layout have a property called "layout" that is set to the id of the containing layout widget. They also have a property called "container" that is set to a number which represents the specific container within the layout widget. Layouts like the Accordion have multiple containers that widgets can be added into.

Are you interested in adding all the widgets created from the conversion into a layout container that is added from the theme's "items" array? Or did you have some other use in mind, can you explain?

I was putting together an example for you of adding the widgets into a layout from the "items" array, and I ran into a roadblock. The ids of widgets added from the "items" array are prefixed with the display file name and record format name (to avoid duplicate ids when multiple formats are overlaid together at runtime), but the scripting hooks have no way to know the file name, so they cannot produce the proper layout container id.

Let me know if this is what you were trying to do -- since those ids are prefixed like that, the scripting hooks must have access to the file name, it must be an oversight that it's not available. We could look at adjusting the parameters for those functions so that you can do this sort of thing.

Re: Adding widgets programatically to layout

Posted: Wed May 21, 2014 10:22 am
by mpilo0
That is indeed exactly what we were trying to do. We had successfully added the layout to the screen. We were also working with the add enhancements in order to add them to the layout. I didn't think that we had to set the container. We are adding to a simple layout so there is only one container. Setting this shouldn't be too complex after, although your example would of course be welcome.

Will this work in profound V5.0?

Re: Adding widgets programatically to layout

Posted: Fri May 23, 2014 12:22 pm
by David
For a simple layout container, you have to set a property on the widget "container" to "1", along with setting the property "layout" to the appropriate id.

Of course, we'll need to make some adjustments before you could actually determine the correct id to use. I think the way this will work is that the conversion process will just pass the file name to the scripting hooks as an additional parameter.

We will make this modification for our next update to the product.

Re: Adding widgets programatically to layout

Posted: Mon May 26, 2014 2:51 pm
by mpilo0
Ok perfect

this will be in version 5?

Thanks

Re: Adding widgets programatically to layout

Posted: Mon May 26, 2014 5:31 pm
by Scott Klement
It will be in version 5, yes. In fact, it will be in our next release of Profound UI. (Which may come earlier than 5, we haven't yet decided.)

Re: Adding widgets programatically to layout

Posted: Tue May 27, 2014 9:04 am
by mpilo0
Isn't version 5 scheduled to release within the next 2-3 weeks?

Re: Adding widgets programatically to layout

Posted: Tue May 27, 2014 10:35 am
by Scott Klement
Version 5 will be released in June, but there is no specific date. 2-3 weeks does seem likely.

It's possible that there might be a 4.x.x release prior to that. This has not been decided.

Re: Adding widgets programatically to layout

Posted: Thu Jun 05, 2014 12:51 pm
by David
Confirming that this will be available in next release, it's complete in dev.

Added an additional argument to "add enhancements", "grid enhancements", and "process fkey" that has the source member name.

Re: Adding widgets programatically to layout

Posted: Fri Jun 06, 2014 2:59 pm
by mpilo0
Thanks David and Scott!