addItemByDim(dim: PP.Mb.DimSource);
dim. Dimension, a metabase object.
The addItemByDim method adds dimension to a collection that is a metabase object.
This method returns an object of the type PP.Mb.DimSelection.
To execute the example, the HTML page must contain an instance of the DimSelectionSet class named dimSelSet (see the page DimSelectionSet Constructor). Clear the collection of dimensions, and next add to this collection dimension with the key 106:
// Get dimension with the 106 key var dim; var item = dimSelSet.getItem(106); if (item != null) { dim = item.getDimension(); }; console.log("Number of dimensions before their deleting from collection: " + dimSelSet.getItems().length); // Delete all selections from collection dimSelSet.clearItems(); console.log("Number of dimensions after their deleting from collection: " + dimSelSet.getItems().length); // Add a new dimension to collection dimSelSet.addItemByDim(dim); // Get information about all dimensions in collection for (var i in dimSelSet.getItems()) { var dimSelection = dimSelSet.getItems()[i]; var key = dimSelection.getDimension().getKey(); var name = dimSelection.getDimension().getName(); console.log("key of added dimension: " + key + ", name: " + name); };
After executing the example the browser console shows the number of dimensions in the collection before and after the elements are deleted, and also key and name of the added dimension:
Number of dimensions before they are deleted from collection: 5
Number of dimensions after they are deleted from collection: 0
Key of the added dimension: 106, name: Calendar
See also: