LimeReport Forum
General Category | Основное => Discussion | Обсуждение => Topic started 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
-
Sure, using scripts.
See the samples
https://github.com/fralx/LimeReport/blob/master/demo_r1/demo_reports
change_item_from_script.lrxml
-
Have tried nearly every combination from the "chang_item_from_script.lrxml" but nothing works. :'(
-
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?
-
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};
}
-
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
-
u a welcome.
also, you can see he alternatebackgroundcolor property of databand. May it will be useful to you