assignSelection(dim: PP.Mb.DimSource, args: Object, callback: Function | PP.Delegate, errorCallback: Function | PP.Delegate);
dim. Dictionary.
args. Operation arguments. An object must contain the following fields: selId - selection moniker; assignOdId - imported selection moniker; append - indicates if the selection is added to the existing one; if the argument if set to True, the selection is added to the existing one; keepGroup - indicates if the set element schemas are saved; if the argument is set to True, the set schemas are saved; applyTransform - indicates if elements are transformed; if the argument is set to True, elements are transformed; fireEvent - indicates if the DimSrv.SelectionChanged is called; if the argument is set to True, the event is called.
callback. Callback function.
errorCallback. Callback function on error.
The assignSelection method selects dictionary elements by the specified moniker.
Executing the example requires an object of the DimSrv class named dimService (see DimSrv Constructor). Set selection for all child elements of the element with the YEARS:2000 key and get names of all selected elements:
// Add a handler of element selection change event dimService.SelectionChanged.add(function(sender, args) { console.log("Element selection is changed"); }); // Set selection for all child elements of the element with the YEARS:2000 key var args = { keys: ["YEARS:2000"], selCommand: PP.Mb.SelCommands.Select, dmElRelative: PP.Mb.DmElRelative.Children }; dimService.selectByKeys(dim, args); // Get names of all selected dictionary elements var func = function(sender, args) { var res = JSON.parse(args.ResponseText); var elems = res.GetDimElementsResult.els.e; console.log("Names of selected elements:"); for (var i in elems) { console.log(elems[i].n); } } dimService.getAllSelectedEls(dim, func);
After executing the example the console displays names of all selected elements:
Names of selected elements:
I quarter 2000
II quarter 2000
III quarter 2000
IV quarter 2000
Now use the program code to open a copy of the dimension and transfer selection from the first dimension:
// Create a copy of dimension var dim2 = dim.clone(); // Transfer selection from the first dictionary var args = { assignOdId: dim.getOdId(), append: True } dimService.assignSelection(dim2, args); // Get names of all selected elements of new dictionary var func = function(sender, args) { var res = JSON.parse(args.ResponseText); var elems = res.GetDimElementsResult.els.e; console.log("Names of selected elements of new dictionary:"); for (var i in elems) { console.log(elems[i].n); } } dimService.getAllSelectedEls(dim2, func);
As a result the console displays names of selected elements of new dictionary:
Names of selected elements of new dictionary:
I quarter 2000
II quarter 2000
III quarter 2000
IV quarter 2000
See also: