getChildren(metaDim: PP.Ufe.MetaSource, args: Object, callback: Function|PP.Delegate, errorCallback: Function|PP.Delegate);
metaDim. Metadata tree model.
args. Arguments. Contains an object with the fields: parentKey - parent element key; range - range of requested elements; filter - element filter; fireEvent - indicates whether the ChildLoaded event is fired after loading elements; if the argument is set to True, the event is fired. By default the argument is set to True.
callback. Callback function.
errorCallback. Callback function on error.
The getChildren method returns child elements according to passed parameters.
Executing the example requires an instance of the MetaTree class metaTree (see MetaTree Constructor). Add a handler of the event of loading child elements by service. Get child elements of the parent element with the Sources name:
// Get metadata tree model var metaSource = metaTree.getSource(); // Get class object of used to work with metadata tree service var metaService = metaTree.getService(); // Add a handler of the event of loading child elements metaService.ChildLoaded.add(function(sender, args) { console.log("Child elements are loaded"); }); // Get child elements of the parent element with the Sources name var func = function(sender, args) { var res = JSON.parse(args.ResponseText); var elems = res.GetTreeElementsResult.els.e; if(elems) { console.log("Names of obtained child elements:"); for (var i in elems) { console.log(elems[i].n); metaSource.setTotalCount(elems.length, args.filter ? args.filter : metaSource.getDefaultFilter()); }; } }; var args = { parentKey: 0 }; metaService.getChildren(metaSource, args, func);
As a result the console displays names of child elements of the parent element with the Sources name, and information that child elements are loaded:
Names of obtained child elements:
Socially economic indicators
Child elements are loaded
Get the number of loaded elements that satisfy basic filter of metadata tree model:
// Get the number of loaded elements that satisfy basic filter
console.log("Number of loaded elements: " + metaSource.getTotalCount(metaSource.getDefaultFilter()));
As a result the console displays the number of loaded elements that satisfy basic filter:
Number of loaded elements: 1
See also: