Example of Creating the DimTree Component

Before executing the example see recommendations for code writing. Make sure that the repository contains a dictionary with the 102770 key.

To create the DimTree component, use the HTML code:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>DimTree</title>
    <script type="text/javascript" src="../build/PP.js"></script>
    <script type="text/javascript">
        PP.scriptManager.loadStyles(["../build/PP.css",
            "../build/PP.App.css",
            "../build/PP.Metabase.css",
            "../build/PP.Dictionaries.css"]);
    </script>
    <script type="text/javascript" src="../resources/resources.ru.js"></script>
    <script type="text/javascript" src="../build/PP.Metabase.js"></script>
    <script type="text/javascript" src="../build/PP.Dictionaries.js"></script>
    <script type="text/javascript" src="../build/PP.App.js"></script>
    <script src="../build/PP.App.js" type="text/javascript"></script>
    
    <script type="text/javascript">
        var metabase;
        PP.ImagePath = "../build/img/";
        PP.ScriptPath = "../build/";
        PP.CSSPath = "../build/";
        PP.resourceManager.setRootResourcesFolder("../Resources/");
        PP.resourceManager.setResourceList(['PP', 'Metabase', 'Dictionaries']);
        PP.setCurrentCulture(PP.Cultures.ru);
 
        function onLoad()
        {
            // Set up repository connection
            var waiter = new PP.Ui.Waiter();
            this.metabase = new PP.Mb.Metabase({
                // Set web service URL in the format:
                // <http://<ServerName | IP-address>[:<Port>][/<VirtualCatalog>]/axis2/services/PP.SOM.Som>
                PPServiceUrl: "http://localhost/fpBI_App_v9.2x64/axis2/services/PP.SOM.Som",
                // Specify repository identifier and credentials
                Id: "Repository",
                UserCreds: {
                    UserName: "user",
                    Password: "password"
                },
                StartRequest: function () {
                    // When requesting metadata specify component of the PP.Ui.Waiter type
                    waiter.show();
                },
                EndRequest: function (sender, args) {
                    // Hide component of the PP.Ui.Waiter type
                    waiter.hide();
                },
                Error: function (sender, args) {
                    // Display error description
                    console.log(args.ResponseText);
                }
            });
            // Open repository connection
            metabase.open();
  
            // Create a service Создадим сервис для работы с измерениями
            var dimSrv=new PP.Mb.DimSrv({ Metabase: metabase});
            // Open dictionary with the 102770 key
            var dimSubj = dimSrv.open(102770, false, true, null, null, null);
 
            // Create the DimTree component
            dimTree = new PP.Mb.Ui.DimTree({
                Source: dimSubj,
                ParentNode: document.getElementById("example"),
                Width: 400,
                Height: 400,
                Service: dimSrv,
                SelectionMode: PP.Ui.TreeListSelectionMode.SingleSelect
            });
        };
        window.onclose = function(){
            alert("Close connection!");
            if (this.metabase !== undefined)
            this.metabase.close();
        };
    </script>
</head>
<body onload="onLoad()">
    <div id="example"></div>
</body>
</html>

After executing the example the HTML page contains the DimTree component that displays the tree of dictionary elements with the 102770 key:

Multiple selection of elements is disabled for this tree.

See also:

DimTree