Discussions
Categories
Groups
Community Home
Categories
INTERNAL ENABLEMENT
POPULAR
THRUST SERVICES & TOOLS
CLOUD EDITIONS
Quick Links
MY LINKS
HELPFUL TIPS
Back to website
Home
Intelligence (Analytics)
Setting the style programmatically
devp
Hi
Is it possible to set the style for a table using a .css file, programmatically. I have a dynamic column table and need to set the style using a css file.
I do not want to use the designer, if possible.
Thanks
devp
Find more posts tagged with
Comments
mwilliams
Hi devp,<br />
<br />
Take a look at this devShare post:<br />
<br />
<a class='bbc_url' href='
http://www.birt-exchange.com/devshare/designing-birt-reports/539-birt-dynamically-choose-css-file/'>BIRT
: Dynamically choose CSS File - Designs & Code - BIRT Exchange</a><br />
<br />
Hope this helps.
devp
Hi Michael
Thank you for the reply. I tried it and it works fine, provided that there is no initial style applied to the table in the designer. But if some style is already applied it does not work.
Also I have a question, in the script we are 'adding' the css to the design handler, does that mean that this style will be applied to all other elements within the report?
Thanks
devp
mwilliams
devp,
Whatever styles you have in your .css like .table-header, etc. will be applied to all elements in the report that meet that description I believe. I could be wrong though. Here is some more sample code that may help you out:
To add a style sheet to the report design
dh = reportContext.getDesignHandle();
sslist = dh.getAllCssStyleSheets();
if( sslist.size() > 0) {
ssh = sslist.get(0);
dh.dropCss(sshandlelist);
}
sh = dh.openCssStyleSheet( "CSS_Filename.css");
dh.addCss( sh );
To apply a certain style to the table either use the default style names in the css or use code like:
th = reportContext.getDesignHandle().findElement("mytable");
th.setProperty("style", "NewStyle");
devp
Thank You for the reply. I did try and it looks like you are right, it does get applied to all the elements which uses the same class. It does appear to be the logical approach.
regards
devp