LimeReport Forum

General Category | Основное => Discussion | Обсуждение => Topic started by: corveejet on February 03, 2021, 12:44:11 PM

Title: How use condition in GroupBandHeader
Post by: corveejet on February 03, 2021, 12:44:11 PM
Hi everyone,

My problem is that: i want to hide a GroupHeaderBand (which contains different shapes and a Text label) depending on if my datasource is empty.

I try to make in condition fields of GroupHeaderBand :
Code: [Select]
$S{
THIS.isVisible = true
if($D{recipe.heading5} === "")
{
    THIS.isVisible = false
}
}

but no success.

Can you help me please ?

Regards.
Title: Re: How use condition in GroupBandHeader
Post by: Subst on February 04, 2021, 02:58:43 PM
I think so.. try to look the printIsEmpty property of bands. It must be to false.
And to labels too
Title: Re: How use condition in GroupBandHeader
Post by: corveejet on February 04, 2021, 04:36:51 PM
thanks for your answer,

I have already put that. I not describe all. I arrived to hide a single goupbandheader (1 groupbandheader connected to band) but i not arrive to hide several groupbandheader (groupbandheader connect to another which is connect to band for example) or i have a strange behavior with a groupheader hide and other not. I put my lrxml in attachments if you want.
Title: Re: How use condition in GroupBandHeader
Post by: Arin Alex on February 05, 2021, 11:42:07 AM
corveejet, Hi!
If you need to hide a whole band you can use beforePrint event from this band.
For example, you can write in the init script something like this:
Code: [Select]
ReportPage1_GroupBandHeader1.beforeRender.connect(BFP);
function BFP(){
   ReportPage1_GroupBandHeader1.isVisible = getField("orders.OrderID")!="10062"
}
Title: Re: How use condition in GroupBandHeader
Post by: corveejet on February 05, 2021, 06:20:26 PM
Arin Alex, Thanks.

It's work perfectly.

Just another question, i'm not very good in js but is there a better way to connect each object to different function?

Code: [Select]
Reportpage1_GroupBandHeader24.beforeRender.connect(BFP_heading1);
Reportpage1_GroupBandHeader25.beforeRender.connect(BFP_heading2);

function BFP_heading1()
{
Reportpage1_GroupBandHeader24.isVisible = (getField("recipe.heading1") != "");
}

function BFP_heading2()
{
Reportpage1_GroupBandHeader25.isVisible = (getField("recipe.heading2") != "");
}

I would like somethings like this, but it doesn't work.

Code: [Select]
Reportpage1_GroupBandHeader24.beforeRender.connect(BFP(Reportpage1_GroupBandHeader24 "recipe.heading1"));

function BFP(object, header)
{
object.isVisible = (getField(header) != "");
}

regards.
Title: Re: How use condition in GroupBandHeader
Post by: Arin Alex on February 05, 2021, 07:32:48 PM
corveejet,
You can use something like this:
Code: [Select]
Reportpage1_GroupBandHeader1.beforeRender.connect(()=>{BF(Reportpage1_GroupBandHeader1, "master.CustomerID")})
function BF(object, field){
object.isVisible = (getField(field) != "ANATR")
}
Title: Re: How use condition in GroupBandHeader
Post by: corveejet on February 06, 2021, 12:18:45 PM
Arin Alex, ok thank you very much.

This Topic is closed now.  ;)