Adding widgets programatically to layout
-
- Profound User
- Posts: 49
- Joined: Wed Jan 08, 2014 11:49 am
- First Name: Michael
- Last Name: Pilote
- Company Name: Oceanex
- Phone: (514) 875-8558
- State / Province: Quebec
- Country: Canada
- Contact:
Adding widgets programatically to layout
Is there a way upon conversion to automatically add widgets to a layout?
- David
- Profound Logic Staff Member
- Posts: 690
- Joined: Fri Jan 04, 2008 12:11 pm
- First Name: David
- Last Name: Russo
- Company Name: Profound Logic Software
- Contact:
Re: Adding widgets programatically to layout
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.
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.
-
- Profound User
- Posts: 49
- Joined: Wed Jan 08, 2014 11:49 am
- First Name: Michael
- Last Name: Pilote
- Company Name: Oceanex
- Phone: (514) 875-8558
- State / Province: Quebec
- Country: Canada
- Contact:
Re: Adding widgets programatically to layout
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?
Will this work in profound V5.0?
- David
- Profound Logic Staff Member
- Posts: 690
- Joined: Fri Jan 04, 2008 12:11 pm
- First Name: David
- Last Name: Russo
- Company Name: Profound Logic Software
- Contact:
Re: Adding widgets programatically to layout
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.
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.
-
- Profound User
- Posts: 49
- Joined: Wed Jan 08, 2014 11:49 am
- First Name: Michael
- Last Name: Pilote
- Company Name: Oceanex
- Phone: (514) 875-8558
- State / Province: Quebec
- Country: Canada
- Contact:
Re: Adding widgets programatically to layout
Ok perfect
this will be in version 5?
Thanks
this will be in version 5?
Thanks
-
- Experienced User
- Posts: 2711
- Joined: Wed Aug 01, 2012 8:58 am
- First Name: Scott
- Last Name: Klement
- Company Name: Profound Logic
- City: Milwaukee
- State / Province: Wisconsin
Re: Adding widgets programatically to layout
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.)
-
- Profound User
- Posts: 49
- Joined: Wed Jan 08, 2014 11:49 am
- First Name: Michael
- Last Name: Pilote
- Company Name: Oceanex
- Phone: (514) 875-8558
- State / Province: Quebec
- Country: Canada
- Contact:
Re: Adding widgets programatically to layout
Isn't version 5 scheduled to release within the next 2-3 weeks?
-
- Experienced User
- Posts: 2711
- Joined: Wed Aug 01, 2012 8:58 am
- First Name: Scott
- Last Name: Klement
- Company Name: Profound Logic
- City: Milwaukee
- State / Province: Wisconsin
Re: Adding widgets programatically to layout
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.
It's possible that there might be a 4.x.x release prior to that. This has not been decided.
- David
- Profound Logic Staff Member
- Posts: 690
- Joined: Fri Jan 04, 2008 12:11 pm
- First Name: David
- Last Name: Russo
- Company Name: Profound Logic Software
- Contact:
Re: Adding widgets programatically to layout
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.
Added an additional argument to "add enhancements", "grid enhancements", and "process fkey" that has the source member name.
-
- Profound User
- Posts: 49
- Joined: Wed Jan 08, 2014 11:49 am
- First Name: Michael
- Last Name: Pilote
- Company Name: Oceanex
- Phone: (514) 875-8558
- State / Province: Quebec
- Country: Canada
- Contact:
Re: Adding widgets programatically to layout
Thanks David and Scott!
Who is online
Users browsing this forum: No registered users and 1 guest