LimeReport Forum

General Category | Основное => Discussion | Обсуждение => Topic started by: Paul Traut on October 19, 2017, 12:35:35 PM

Title: changing color
Post by: Paul Traut 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
Title: Re: changing color
Post by: Subst 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
Title: Re: changing color
Post by: Paul Traut on October 19, 2017, 03:58:19 PM
Have tried nearly every combination from the "chang_item_from_script.lrxml" but nothing works. :'(
Title: Re: changing color
Post by: Subst 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?
Title: Re: changing color
Post by: Subst 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};
 }
Title: Re: changing color
Post by: Paul Traut 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
Title: Re: changing color
Post by: Subst 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