I'm a noob and I'm looking to dynamically modify some of the styling based on customer preferences. In addition, I'm looking to run date column values through a scrubber to set the format dynamically.
Adding HTML Data Attributes to report elements
Can you dive slightly deeper into the use cases (what exactly you would like to setup in regards to dynamic styling)? There are different ways to change the styling based on the customer preferences and I'm not sure how you want it to work in your case and how it is related to the post title.
As for scrubbing the date column values - this is usually done in the Data Cube using a data conversion transform or a calculated element transform depending on the rules you need to apply to set the proper format.
Sounds like he wants certian user to see one date formate and other to see a different one and so on.
Could this be accompished with Groups and setting a date format (Culture) that has the format he wants for that group?
The same Culture is on each account but seams wiser to make groups and add people rather than set a group pf people to a speific culture.
Then he does not have to do anything in the datacube.
For instance, Customer 1 wants the title of a report to have a red background and a date format of 'mm/dd/yyyy'. Customer 2 would like to have the same report to have a blue title field and a date format of 'dd-mm-yyyy'. I have some JS that will scrub the dates, if I can pinpoint them. I've also dynamically set a field background color. Without a data attribute, however, it's hard to reliably pinpoint the exact elements.
I think you should try using the Culture in Dundas to see if that will solve the Date format issue.
As far as the color sounds like you got a solution that works and I would be interested in see how you did that. (I have this one person in my organization that does not like the back ground I have and want it to be printer friendly, I could use this to give that to this person).
Sure, it would be a lot easier, however, if i had actual ids or data attributes on which to locate the correct elements. For now I've just viewed the source and grabbed the first instance. I just need something to identify them and I don't see anything unique. The GUID doesn't seem to correspond to the element and the Script Name seems to not be in the HTML.
var updateColor=function(){
var myLabel=$('.labelControlLabel').first();
//alert("Title current background color=" + myLabel.css('background-color') + "\nThis is now going to be changed to purple");
myLabel.css({"background-color":"purple","color":"white","font-size":"20px"});
};
setTimeout(updateColor,3000);
put that into the Page Ready script
in your script put
debugger;
then when it hits have the dev tools open and from inside there start exploring things like wait...
just go here and look around
https://www.dundas.com/Support/developer/script-library/
there are ways to get to what you are looking for.
https://www.dundas.com/support/api-docs/js/ (not as usfull as it could be but gives you some ideas on what to explore)
Not sure why you are needing to use HTML and not the built in scripts within BI? Each element will have a script name that you can use to identify it.
Thanks for the responses.
RE: debugger: I'm familiar.
RE: why use HTML:
I'm not sure, either, honestly. I'm not that familiar with the product yet, so it's entirely possible that there is something inherent that would obviate this entire endeavor. My thinking is that I we would have these configurations (css/formats) stored on our end and impose those on the reports as they're being loaded via the embedding process. In this way, the formats and stylings are generic and can be reflected immediatlely upon the report loading. What i'm using is not HTML, but JQuery. I'm using a client-side script to pull off this bit of wizardry.
I have tried to do this through the BI scripting but Script Name is not present, from what I've seen, in the HTML for the report.
But I guess, to settle the CSS part, I should ask if there is a way to dynamically theme reports based on particular users.
So after doing some more digging I think that tenanting is what I'll be able to use for the theming.
Part of the date issue is not that it's particular to the localization settings. The dates in the filtering label - indicating the current result set, and not the actual filters - contains ">=" and "<=" values and a predetermined date format. We currently have an extension to override this value, but I was hoping it could all be rolled up into one process. If not, so be it.
Hi Chaz, I wanted to shed more light in regards to your comment:
"I have tried to do this through the BI scripting but Script Name is not present, from what I've seen, in the HTML for the report."
In reports (unlike dashboards), content may be generated across a repeated hierarchy and thus “label1” you added to the body of the report is not the same label(s) that ends up in the report which receives a random name instead.
As a result if you were to use a script such as:
label1.background = new dundas.controls.SolidColorBrush('DundasOrange');
in order to color the background of a label placed in your report body and place it on the report "Ready" action there will be no impact (unlike in the dashboard where the label background will change). To use this type of script on a report, you can move the script to the "Data Changed" action of one of the data visualizations within the same body section of your report. This script will then be evaluated before the label is assigned a random name and thus the background color change will work.