0

this is my first question ever, so please be patient. :-)

I am using BIRT (ECLIPSE) to create a report, which has several tables. I want many of the cells in these tables to feature the same highlighting rules (colored backgrounds, fond formatting, etc.), based on the same rules (e.g. value equals minus 5). Ideally, I want to use these highlighting rules in other reports as well, but that's not as important.

If possible, I would like to create a STYLE which includes the highlighting rule (because then I could simply apply this everywhere I need), but I can't figure out how to fill in the condition box, since the name of the applicable object will vary.

If a STYLE is not possible or not recommended, I would also be happy to loop through the tables using the Script, but I have no idea how to do this.

Thanks in advance!!!

Johannes

Johannes
  • 21
  • 4

2 Answers2

0

Yes, you can use CSS to write a style and then apply on conditional situation using jQuery

// jQuery
    if($('selector').val() == -5){
       $('selector').addclass('cssClass1');
    }else{
       $('selector').addclass('cssClass2');
    }


/* CSS */
    .cssClass1{color: red;}
    .cssClass2{color: blue;}

This should work

JoelBonetR
  • 1,551
  • 1
  • 15
  • 21
  • thanks a lot for the quick response! Unfortunately I get this error message when importing : [4:11] encountered "$". Was expecting one of: "}" ";" Also, it doesn't seem to do anything when applied to the data field. – Johannes Sep 26 '16 at 09:25
  • you need to apply it on an event function as, for example $( ".target" ).change(function() { /* jquery pasted before */ } and you need to add jquery library. I'm not too used with eclipse (java), so i cannot tell you more than i said i think, sorry. Try to google how insert jquery function inside a java file – JoelBonetR Sep 26 '16 at 09:47
0

In case anyone comes across this question in the future, this is how I solved it:

First, I created a function called highlight_1:

function highlight_1(Feld) {
    if (Feld.getValue() <= -0.75) {
        Feld.getStyle().backgroundColor = "#FF8040"
        Feld.getStyle().color = "Black";
    } else if (Feld.getValue() <= -0.25) {
        Feld.getStyle().backgroundColor = "#FFFF80"
        Feld.getStyle().color = "Black";
    } else if (Feld.getValue() >= 0.03) {
        Feld.getStyle().backgroundColor = "#97D9A2"
        Feld.getStyle().color = "Black";
    } else {
        Feld.getStyle().backgroundColor = "#00874E"
        Feld.getStyle().color = "White";
    }
}

I then call this function for each element in the onRender event like this:

highlight_1(this)

It's not exactly what I had in mind, but it works without too much effort needed for each new element.

Johannes
  • 21
  • 4