TIP: Implementing a Dashboard Level javascript function

Have you come to a situation where you need to repeat lines of code in your dashboards? Maybe you have thought of putting in to the javascript override but it is too specific to your dashboard.

Implementing a dashboard level function might be the solution for you.

on the loading event of the dashboard: we add a function expression. This function would be a attached to the dashboard object and will be accessible across the dashboard.

example: (on the loading event of the dashboard)
`this.setDateWithLevel = function(date, level, viewParameter)
{
var upperDateValue = new dundas.data.MemberValue(
{
hierarchyUniqueName: “DataEventTime”,
levelUniqueName: level,
uniqueName: date
}
);

  var lowerDateValue = new dundas.data.MemberValue(
    {
      hierarchyUniqueName: "DataEventTime",
      levelUniqueName: level,
      uniqueName: date
    }
  ); 

  viewParameter.parameterValue.upperBoundaryValue = upperDateValue;
  viewParameter.parameterValue.lowerBoundaryValue = lowerDateValue;
}

then if we need to call this on an event of an object inside the dashboard, the call would be like this:
this.parentView.setDateWithLevel(uName, DAY_LEVEL_UNIQUE_NAME, vpDate);

Imagine the lines of code that are saved, as well as the maintainability of the code.

2 Likes

Thanks for the TIP Renzi. :+1:

1 Like