Change Cell Text Color when Clicked

Hello,

Was wondering if it was possible if the text color for a specific cell on a table could be changed when clicked via scripting or another method.

I’ve attached a sample of what the table data looks like. For example, when the end user clicks on Cell C3, only the text color in C3 would change.

The high-level business requirement for this is that a customer order milestone may have occurred already, but our customer rep may not want to show this in the report to the customer, so by clicking the cell it could change the cell text color to white. Sample%20Data

You can change the color of a table cell using the table click event, just put the following script on:
if (e.relatedData) {
e.relatedData._hitTestResult.cell.style.color = “red”
}

Thanks Luis, this is great.

Is there a way I could possibly toggle this back and forth? So if they were to click it again, I could specify another color to change the cell to? And subsequent clicks would just alternate between two colors?

You can do something like this:

if (e.relatedData) {
  if (e.relatedData._hitTestResult.cell.style.color == '' || e.relatedData._hitTestResult.cell.style.color == 'blue') {
  	e.relatedData._hitTestResult.cell.style.color = "red";
  }
  else if (e.relatedData._hitTestResult.cell.style.color == "red") {
    e.relatedData._hitTestResult.cell.style.color = "blue";
  }
   
}

Thanks Luis, this works great. It seems that this formatting doesn’t preserve when the dashboard is exported to PDF, image, powerpoint, etc. Is there a way Dundas can preserve this formatting?

You are using JavaScript to do this and it works fine when you are viewing the dashboard, because JavaScript works on the client side, however when exporting the dashboard, the rendering of the dashboard comes from server side and it gets the color scheme that you define in the properties of the objects in design mode! If you could somehow identify a criterion for the cells that you would like to change the color, you could use states for the data and this way, you would get the result expected when exporting.

When exporting to Excel you can just change the colors in the cells. but for PDF or Image you would have an issue.

Thanks all.

Luis, do you know if it is possible to set up states on dimensions? So for example, the way our data is set up, if the original application has a field that is not populated, it will pull in the date of ‘1899-12-30’, but this is a dimension field so I can’t apply a state group to it. Is there a workaround for this?

You could create a calculated measure on the data cube and if the date is equal to ‘1899-12-30’ then you return 1 else return 0. This way you’ll have a measure that you can use for setting up a state group. Something like this:

DateTime date1 = new DateTime(1899, 12, 30, 0, 0, 0);
if (date1 == $MaxDate$) { return 1; }
else { return 0; }

Thanks Luis. Much appreciated.