selectLevel(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; groupId - group identifier; selCommand - operation type, element of the PP.Mb.SelCommands enumeration; fireEvent - indicates if the DimSrv.SelectionChanged event is called; if the parameter is set to True, the event is called.
callback. Callback function.
errorCallback. Callback function on error.
The selectLevel method selects elements on the specified level.
To execute the example, the HTML page must contain the DimTree component named dimTree that uses the dim dictionary as its source (see Example of Creating the DimTree Component). Determine a time interval taken by dictionary elements considering the selected level:
// Create a service for working with dictionaries var dimService = new PP.Mb.DimSrv({ Metabase: mb }); // Create a data source var dimSource = new PP.Mb.DimSource({ Metabase: mb }); function selectLevel(level) { var args = { selId: dim.getOdId().id, levelId: level, selCommand: PP.Mb.SelCommands.Select, fireEvent: True }; function callback(sender, args) { // Read server response var res = JSON.parse(args.ResponseText); var res = JSON.parse(args.ResponseText); var firstSelected = PP.getProperty(res, "ChangeDimSelectionResult.selectionInfo.firstSelected"); var lastSelected = PP.getProperty(res, "ChangeDimSelectionResult.selectionInfo.lastSelected"); if(firstSelected && lastSelected) { console.log("%s - %s", firstSelected.n, lastSelected.n); } }; function errCallback(sender, args) { if(args) { console.log(args.ResponseText); } }; dimSource.addSelection(dim.getOdId()); // Select element selection for the selected level dimService.selectLevel(dimSource, args, callback, errCallback); }; // Set selection for elements of the Year level selectLevel(1); // Set selection for elements of the Quarter level selectLevel(3); // Set selection for elements of the Month level selectLevel(4);
After executing the example the browser console displays the time interval that covers all dictionary elements considering the selected levels - month, quarter, year:
1990 - 2005
1990 - IV quarter 2005
1990 - Dec 2005
See also: