Linking a report or reportlet gadget to a tree selector
If you link a report or reportlet gadget to a tree selector in a dashboard, a dashboard user can provide values for report parameters using the tree selector. The report developer, however, must include code in the report design that consumes the JavaScript output of the tree selector as a filter. For example, the following code snippet consumes the expression Tree Filter Expression produced by a tree view selector. This code appears in the beforeFactory script, as shown in Figure 4‑66.
var expressionStr = params["Tree Filter Expression"].value;
 
var filterCondition = StructureFactory.createFilterCond( );
filterCondition.setExpressionProperty( 
FilterConditionElementHandle.EXPR_PROP, new Expression(expressionStr, ExpressionType.JAVASCRIPT ));
filterCondition.setOperator( 
DesignChoiceConstants.FILTER_OPERATOR_TRUE );
filterCondition.setFilterTarget( 
DesignChoiceConstants.FILTER_TARGET_DATA_SET );
 
var table = reportContext.getDesignHandle().findElement( 
"Main Table" );
var propHandle = table.getPropertyHandle( "filter" );
propHandle.addItem( filterCondition );
Figure 4‑66 beforeFactory script