JavaScript

{dialog.object}getTopParentObject Method

Syntax

{dialog.object}.getTopParentObject();

Returns

resultobjectboolean

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

Description

Returns a pointer to the top most parent object.

Discussion

If the UX component was opened from a parent Grid or UX component, which in turn was opened from another Parent Grid or UX, and so on, returns a pointer to the top most parent object.

Example

//Get a pointer to the top parent object
var po = {dialog.object}.getTopParentObject();

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

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

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

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

See Also