DimSource.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 DimTree component named dimTree (see. Example of Creating the DimTree 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();
 //Enable to have elements with data in source            
 dim.setAllowHasData(true);
 //Set the attribute that there are data 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();
 //Return TreeList which the DimTreeView component basis
 cont = dimTree.getControl();
 //Set highlighting color
 cont.setHighlightColor("SkyBlue");
 //Display to the console that there are data for the first element
 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:

DimSource