Dimension.setDataEls

Syntax

setDataEls (els, clearOld);

Parameters

els. Array of elements that contain data.

clearOld. Determines whether to clear the current array of elements containing data on method execution. By default it is set tp False, and the current array is not cleared.

Description

The setDataEls method sets array of dimension elements that contain data.

Comments

Dimension elements must be specified as metadata, with the @hasData field set to True, for example: { k: "YEARS:2003", "@hasData": True }

Example

To execute the example, the HTML page must contain the DimensionTree component named dimTree (see Example of Creating the DimensionTree Component). The source dictionary must include elements with the following keys: YEARS:2002, YEARS:2003, YEARS:2004. Determine indication of data availability for these elements and set up their highlighting:

 //Enable highlighting for elements with data           
 dimTree.setAllowHasDataHighlight(True);
 //Get dimension source            
 dim = dimTree.getSource();
 //Allow the source to contain elements with data            
 dim.setAllowHasData(True);
 //Set data availability indicator for three elements            
 dim.setDataEls([{
     k: "YEARS:2002",
     "@hasData": True
            }, {
     k: "YEARS:2003",
     "@hasData": True
            }, {
     k: "YEARS:2004",
     "@hasData": True
            }]);
 //Refresh tree highlighting
 dimTree.refreshHighlighting();
 //Get TreeList that is used as a base for the DimTreeView component
 cont = dimTree.getControl();
 //Set highlighting color
 cont.setHighlightColor("SkyBlue");
 //Show to the console if the data for the first element is available
 console.log(dim.getElemHasDataState(dim.getHasDataElems()[0]));

After executing the example the elements with the keys YEARS:2002, YEARS:2003, YEARS:2004 are highlighted in the tree:

The console shows the word Self, which means that the element with the key YEARS:2002 contains data.

See also:

Dimension