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

Author Topic: How use condition in GroupBandHeader  (Read 4245 times)

corveejet

  • Newbie
  • *
  • Posts: 10
    • View Profile
How use condition in GroupBandHeader
« 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.

Subst

  • Sr. Member
  • ****
  • Posts: 451
    • View Profile
Re: How use condition in GroupBandHeader
« Reply #1 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

corveejet

  • Newbie
  • *
  • Posts: 10
    • View Profile
Re: How use condition in GroupBandHeader
« Reply #2 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.

Arin Alex

  • Developer
  • Administrator
  • Hero Member
  • *****
  • Posts: 1005
    • View Profile
Re: How use condition in GroupBandHeader
« Reply #3 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"
}

corveejet

  • Newbie
  • *
  • Posts: 10
    • View Profile
Re: How use condition in GroupBandHeader
« Reply #4 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.

Arin Alex

  • Developer
  • Administrator
  • Hero Member
  • *****
  • Posts: 1005
    • View Profile
Re: How use condition in GroupBandHeader
« Reply #5 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")
}

corveejet

  • Newbie
  • *
  • Posts: 10
    • View Profile
Re: How use condition in GroupBandHeader
« Reply #6 on: February 06, 2021, 12:18:45 pm »
Arin Alex, ok thank you very much.

This Topic is closed now.  ;)