DItem Constructor

Syntax

PP.Rds.DItem(settings: Object);

Parameters

settings. Class settings.

Description

The DItem constructor creates an instance of MDM dictionary item.

Example

To execute this example, the page must contain the DictionaryBox component named dictionaryBox (see Example of creating the DictionaryBox component ). Create two elements in the MDM dictionary, the second element should be embedded into the first one. Specify a value for the first element:

// Get MDM dictionary
var source = dictionaryBox.getSource()[0];
// Get service for working with the dictionary
var service = source.getPPService();
// Create a new element with the 1711 key
var hourItemKey = "1711";
var hourItem = new PP.Rds.DItem({
    Key: hourItemKey,
    AttrValues: [hourItemKey, "Hour", "", hourItemKey], // Attribute values
    HasChild: true, // The element has child elements
    Name: "Hour",
    Owner: source,
    Level: 0, // Element level in the tree
    ParentKey: source._rootKey // Key of the parent item
});
hourItem._History = [];
// Create the second element with the 1712 key
var minuteItemKey = "1712";
var minuteItem = source.getBlankElement(minuteItemKey);
minuteItem.setAttrValues([]);
// Set attribute values
minuteItem.setAttrValues([minuteItemKey, "Minute", "", minuteItemKey]);
minuteItem.setName("Minute");
minuteItem.setLevel(1);
minuteItem.setHasChild(false);
minuteItem.setParentKey(hourItemKey);
minuteItem._History = [];
// Add the first element to the dictionary model
service.setItem(source, PP.Rds.ElementOperation.Insert, "", null, hourItem, function () {
    // Add the second element
    source.setElement(minuteItem.getParentKey(), minuteItem, true);
    // Get dictionary child elements
    var childEls = source.getChildEls();
    for (var i = 0; i < childEls.length; i++) {
        switch (childEls[i].getKey()) {
            // Specify value for the first element 
        case hourItemKey:
            childEls[i].setValue("UNIT_VALUE", "3600");
            break;
        }
    };
    // Refresh the tree of dictionary elements
    dictionaryBox.getDataArea().getActiveDictTree().refreshAll();
});

Two elements are created as the result of the example execution. The second element Minute with the 1712 key is embedded into the Hour element with the 1711 key. The value 3600 is set for the first element:

See also:

DItem