Welcome, Guest. Please login or register.
Did you miss your activation email?

Author Topic: changing color  (Read 3978 times)

Paul Traut

  • Jr. Member
  • **
  • Posts: 59
    • View Profile
changing color
« on: October 19, 2017, 12:35:35 pm »
Hello, is it possible to create a data band within the designer,  where the text field results change their background color with every new data?

Something like

data1
data2
data3
.
.
.


Paul

Subst

  • Sr. Member
  • ****
  • Posts: 450
    • View Profile
Re: changing color
« Reply #1 on: October 19, 2017, 01:12:26 pm »
Sure, using scripts.
See the samples

https://github.com/fralx/LimeReport/blob/master/demo_r1/demo_reports
change_item_from_script.lrxml

Paul Traut

  • Jr. Member
  • **
  • Posts: 59
    • View Profile
Re: changing color
« Reply #2 on: October 19, 2017, 03:58:19 pm »
Have tried nearly every combination from the "chang_item_from_script.lrxml" but nothing works. :'(

Subst

  • Sr. Member
  • ****
  • Posts: 450
    • View Profile
Re: changing color
« Reply #3 on: October 19, 2017, 05:27:27 pm »
it's works. May be you doing some wrong.
Well let's step by step.

As I see you wonna change color for text in databand. I.e. fist row - one color second - another one and so on...

is that right?

Subst

  • Sr. Member
  • ****
  • Posts: 450
    • View Profile
Re: changing color
« Reply #4 on: October 19, 2017, 05:39:58 pm »
In this case you need some think like follow

$S{
 if (line("BAND_NAME")%2==0)
  THIS.fontColor=QColor('red');
 else
  THIS.fontColor=QColor('blue');
 $D{TABLE_NAME.FIELD_NAME};
 }

Paul Traut

  • Jr. Member
  • **
  • Posts: 59
    • View Profile
Re: changing color
« Reply #5 on: October 19, 2017, 06:11:32 pm »
I have found a solution for my situation

$S{
if ($D{production.AGLEVEL} % 2 == 1)
{
TextItem41.backgroundColor = QColor('#bdbdbd');
TextItem42.backgroundColor = QColor('#bdbdbd');
TextItem43.backgroundColor = QColor('#bdbdbd');
TextItem44.backgroundColor = QColor('#bdbdbd');
TextItem45.backgroundColor = QColor('#bdbdbd');
}
}

this code is in a textfield behind the text fields that i can see.
The Variable "THIS.backgroundColor" didn't work.

Thanks for your help again

Subst

  • Sr. Member
  • ****
  • Posts: 450
    • View Profile
Re: changing color
« Reply #6 on: October 20, 2017, 04:10:21 am »
u a welcome.

also, you can see he alternatebackgroundcolor property of databand. May it will be useful to you