DimSrc.setCalendarPeriod

Syntax

setCalendarPeriod(dim: PP.Mb.DimSource, args: Object, callback: Function|PP.Delegate, errorCallback: Function|PP.Delegate);

Parameters

dim. Dictionary.

args. Operation arguments. An object must contain the following fields: calendarLevel - set calendar period.

callback. Callback function.

errorCallback. Callback function on error.

Description

The setCalendarPeriod method sets a calendar period for a dictionary.

Example

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 the time interval taken by dictionary elements by using different calendar periods:

// Create a service used to work with dictionaries
var dimService = new PP.Mb.DimSrv({
    Metabase: mb
});
function setCalendarPeriod(period) {
    var args = {
        calendarLevel: period
    };
    var readyCallback = function(sender, args) {
        // Read server response
        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);
        }
    };
    var errorCallback = function(sender, args) {
        console.log("Error on setting a calendar period");
    };
    // Set the specified calendar period for dictionary
    dimService.setCalendarPeriod(dim, args, readyCallback, errorCallback);
};
setCalendarPeriod("Month"); // Calendar period - month
setCalendarPeriod("Quarter"); // Quarter
setCalendarPeriod("Year"); // Year

After executing the example the browser console displays the time interval that covers all dictionary elements in different calendar periods - month, quarter, year:

Jan 1990 - Dec 2005

I quarter 1990 - IV quarter 2005

1990 - 2005

See also:

DimSrv