[Javascript] Set custom parent of element created with scout.create()? [message #1773337] |
Tue, 26 September 2017 14:41  |
Eclipse User |
|
|
|
Hey everybody,
I'm generating Scout form fields on the client side via Javascripts scout.create(), in this case a StringField.
var stringField = scout.create('scout.StringField', {
parent: scout.sessions[0].desktop,
labelVisible: true,
name: "test",
value: "testing"
});
As you can see the field is appended to the desktop DOM element. But what we want to do is instead append to a custom, Javascript generated child element of the desktop.
Is that in any way possible without breaking everything?
Thanks for your help,
Marius
|
|
|
Re: [Javascript] Set custom parent of element created with scout.create()? [message #1773664 is a reply to message #1773337] |
Mon, 02 October 2017 14:22  |
Eclipse User |
|
|
|
Hi Marius,
you can use any widget as parent. What you need to take care of is the layouting.
Example: Let's assume you want to put the string field on the bottom of the desktop navigation (on the bottom left of the screen). In that case you would use the navigation (desktop.navigation) as parent and you would have to adjust the DesktopNavigationLayout to tell where the string field should be positioned exactly. In order to do this, you could extend scout.DesktopNavigation, override the function _render, do a super call and set a custom layout for the navigation.
scout.CustomDesktopNavigation.prototype._render = function() {
scout.CustomDesktopNavigation.parent.prototype._render.call(this);
this.htmlComp.setLayout(new scout.CustomDesktopNavigationLayout(this));
};
|
|
|
Powered by
FUDForum. Page generated in 0.03396 seconds