Cognos TM1 Web JavaScript library CubeViewer class

The CubeViewer class represents a Cognos® TM1® Web CubeViewer object.

CubeViewer objects extend the Dojo widget object (dijit._WidgetBase) and can be assigned as a child object of a Dojo tab container (dijit.layout.TabContainer) or other container. For more information, see Dojo documentation (http://dojotoolkit.org/documentation/).

In addition to the available properties and methods of the Dojo widget object, CubeViewer objects also have TM1 related properties and methods that you can access programmatically.

CubeViewer objects are loaded asynchronously and must finish loading before your code can interact with the objects.

Format

You load a CubeViewer object by using the following format to specify the required properties and optional functions that define the object.

new CubeViewer({properties ..., functions ...});

Properties

The properties include the following values that define the CubeViewer object.

  • adminHost
  • tm1Server
  • username
  • password
  • camPassport
  • sessionToken
  • view
  • cube
  • isPublic
Note: You can provide login credentials as either a session token or by including separate values for TM1 Admin host, TM1 Server, user name, password, or camPassport.
Functions

The functions can include the following optional code:

  • Use the onLoad function so that you can be notified when the object is loaded and ready to interact with.
  • Use the onTitleDimensionElementChange declaration so you can process the event when a user changes a dimension title in the related object.

Example

The following example shows a JavaScript function that uses a combination of JavaScript and Dojo syntax to load a CubeViewer object.

The login credentials are provided by using a session token.

function loadCubeview() {
    require([
        "tm1web/cubeview/CubeViewer",
        "dojo/_base/unload"
    ], function(CubeViewer, unload) {
        loadedCubeview = new CubeViewer({
            sessionToken: "yourSessionToken",
            cube: "plan_BudgetPlan",
            view: "Budget Input Detailed",
            isPublic: true,
            title: "Budget Input Detailed",
            onLoad: function() {
                console.debug("CubeViewer loaded successfully.");
            },
        });

        // Assign object to a UI container
        dijit.byId("tabContainer").addChild(loadedCubeview);
        
        loadedCubeview.startup();
        
        unload.addOnUnload(function() {
            loadedCubeview.destroy();
        });
    });
};