Example of Creating the DictionaryBox Component

Before executing the example study recommendations for code writing.

To create the RdsBox component:

  1. Create table MDM dictionaries in the desktop application:

Table MDM dictionary Time Units

Table MDM dictionary System of Units

  1. Use HTML code:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>RdsBox</title>
    <link href="../build/PP.css" rel="stylesheet" type="text/css" />
    <link href="../build/PP.Metabase.css" rel="stylesheet" type="text/css" />
    <link href="../build/PP.Dictionaries.css" rel="stylesheet" type="text/css" />
    <script src="../build/PP.js" type="text/javascript"></script>
    <script src="../build/PP.Metabase.js" type="text/javascript"></script>
    <script src="../build/PP.Dictionaries.js" type="text/javascript"></script>
 
    <script type="text/javascript">
        var dictionaryKey = 8093; // Key of table MDM dictionary Time Units
        function Ready() {
            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);
            // Create a repository connection
            metabase = new PP.Mb.Metabase({
                // Set PP.SOM web service URL in the format:
                // <http://<ServerName | IP-address>[:<Port>][/<VirtualCatalog>]/axis2/services/PP.SOM.Som>
                PPServiceUrl: "http://localhost/FPBI_App_v9.x/axis2/services/PP.SOM.Som",
                // Specify repository identifier and user credentials
                Id: "REPOSITORY",
                UserCreds: {
                    UserName: "user",
                    Password: "password"
                }
            });
            // Open repository connection
            metabase.Error.add(function (sender, args) {
                alert(args.ResponseText);
            });
            metabase.Opened.add(function (sender, args) {
                openDictionaryBox();
            });
            metabase.open();
        }
        // Open table MDM dictionary with the specified key
        function openDictionaryBox() {
            service = new PP.Dictionaries.RdsService({
                Metabase: metabase,
                RdsOpened: function (sender, args) {
                    console.log("Key of opened dictionary: %s", args.Dictionary.getKey());
                    console.log("Identifier of opened dictionary: %s", args.Dictionary.getId());
                },
                RdsClosed: function (sender, args) {
                    console.log("Name of closed dictionary: %s", args.Dictionary.getName());
                }
            });
            source = service.openRds(dictionaryKey, null, true);
            rdsBox = new PP.Dictionaries.Ui.RdsBox({
                Source: source,
                ParentNode: "rdsBox",
                ImagePath: PP.ImagePath,
                Width: 800,
                Height: 400,
                Open: function (sender, args) {
                    source = service.openRds(dictionaryKey, null, true);
                    rdsBox.setSource(source);
                },
                Close: function (sender, args) {
                    // Remove dictionary from container
                    rdsBox.setSource(null);
                    // Close dictionary
                    service.closeRds(source, function (sender, args) {
                        console.log("Key of closed dictionary: %s",
                        args.Args.Dictionary.getKey())
                    });
                    rdsBox.refreshAll();
                }
            });
        }
    </script>
</head>
<body onload="Ready()">
    <div id="rdsBox" style="border: 1px #C3C3C3 solid; width: 805px"></div>
</body>
</html>

NOTE. To execute custom scripts for the container that stores MDM dictionary, including the examples given on the pages that contain descriptions of properties, methods and events of this component and its constituent parts, place the code either in the Ready function or in the browser console.

After executing the example the HTML page contains the RdsBox component that displays the Time Units table MDM dictionary:

The following also occurs during example execution:

Key of the opened dictionary: 8093

Identifier of opened dictionary: TIME_UNITS 

The RdsService.RdsClosed and DictionaryBox.Close events are triggered in this case, after which the browser console displays key and name of the closed dictionary:

Key of the closed dictionary: 8093
Name of the closed dictionary: Time units

See also:

DictionaryBox