HieService.getChildEls

Syntax

getChildEls (hie, parentKey, callback);

Parameters

hie. Sets hierarchy object.

parentKey. Sets value of child element key.

callback. Sets handler for operation execution end.

Description

The getChildEls method is used to load child elements.

Example

To execute the example, in the HEAD tag of the HTML page specify links to the following JS files:

This example requires a time series database with the 1334 key.

In the <body> tag as the value of the onLoad attribute specify name of the function executed after page body loading is finished:

<body onload="Ready()">
	<div id='example'></div>
</body>

In HTML page body add the following script:

<script type="text/javascript">
	// Declare constants
	var RUB_KEY = 1334;
	// Declare variables
	var metabase, hieSrv, hie;
	PP.ImagePath = "../build/img/";
	PP.ScriptPath = "../build/";
	PP.CSSPath = "../build/";
	
	// Dummy factory
	function onDummyActionFactory(actionCaption){
		return function (sender, args){
			console.log(actionCaption);
			console.log(args);
		};
	}
	function Ready() //body loading event handler
	{
		metabase = new PP.Mb.Metabase({
			Id: "pmart_ms",
			UserCreds: { UserName: "sa", Password: "H88cp229" },
			Error: function (sender, args){alert(args.ResponseText);}
		});
		// Open repository connection
		metabase.open();
		hieSrv = new PP.Mb.HieService({ Metabase: metabase });
		hieSrv.HieOpened.add(onDummyActionFactory("Series hierarchy is open"));

		// Create a service used to work with time series
		tsService = new PP.TS.TSService({ Metabase: metabase });
		// Open document
		var wbk;
		tsService.openDocument(RUB_KEY, onWbkOpened);
		function onWbkOpened(sender, args)
		{
			wbk = args.Workbook;
			//Send request to open hierarchy of main workbook factor catalog
			hieSrv.openFromSource (wbk, new PP.Delegate(onOpened), this));
		}

		function onOpened (sender, res)
		{
			//Get metadata hierarchy instance
			hie = res.Args.Hier;
			console.log(hie);
			hieSrv.ElementsLoaded.add(onDummyActionFactory("Child element get event occurred"));
			
			//Send request to get child elements
			hieSrv.getChildEls(hie, "", function(sender, res){
				console.log("Response to child element request is obtained");
				console.log(res);
			
			});
		}
	}
</script>

After executing the example a service for working with hierarchy of time series database is created. Hierarchy of the time series database with the 1334 key opens, and next the console shows an appropriate message. After opening hierarchy of the time series database, the ElementsLoaded event creates and sends a request to get hierarchy children. On firing the HieOpened event the console shows the following message: Event of getting child elements has occurred. After getting the children the console shows the following: Got a response to the child element request.

See also:

HieService