JavaScript

{dialog.object}getParentObject Method

Syntax

{dialog.Object}.getParentObject()

Returns

resultobjectboolean

Returns the JavaScript object for the parent component. The parent object will either be a {grid.object} or {dialog.object}. If no parent object exists, getParentObject() returns false.

Description

If this component is opened from a parent Grid or UX component, this returns a pointer to the parent object so you can execute methods on the parent object.

//Get a pointer to the parent component object that opened this UX.
var po = {dialog.object}.getParentObject();

//If this UX Component does not have a parent then 'po' will be false. 
if (!po) {
    alert("No Parent Object");
}

//Here is how you can tell if the parent component is a Grid or a UX component 
var po = {dialog.object}.getParentObject();
var componentType = '';
if (po) {
     if(typeof po.gridId != 'undefined') { componentType = 'grid'; }
     if(typeof po.dialogId != 'undefined') { componentType = 'ux'; }

     alert("Parent object's component type is " + componentType);
} else {
    alert("No Parent Object");
}

If the UX component does not have a parent object, getParentObject() will return false. You should always check the returned value of the getParentObject() method before using the object. This can be done by wrapping your code in an if block as shown in the example.

Videos

Getting a Pointer to a Parent or Child Component So You Can Call Methods of the Parent or Child Component

The ability to re-use components and open a child component in a window, div, TabbedUI pane, Panel, or embed into a parent component is one of the most powerful aspects of the Alpha Anywhere architecture.

When you open a component from a parent component, you will often want to get a pointer to the child component so you can manipulate it in your Javascript code in some way. For example, you might want some code in the parent component to read a control in the child, or set a value in the child. Similarly, you might want some code in the child component to read or set a control in its parent.

The .getParentObject() and .getChildObject() methods are used to get pointer to an object's parent or child objects.

In this video, we show how this is done.

Download Component