Select to view content in your preferred language

limit data shown in infoWindow component

687
5
10-27-2010 08:21 AM
TracySchloss
Frequent Contributor
I have a component for my infoWindow set up to only show when a particular field has data in it.  This has worked quite well for me to 'close the gap' of blank lines when I don't have data in a particular field. 

I now have an instance where I only want to show "field3" if "field1" and "field2" are both blank.  I tried combining the two, but I'm getting an error.  I don't know if I can't do this, or if I've just got a syntax problem.

<mx:Component className="MyInfoWindowRenderer">
      <mx:VBox verticalGap="-5" height="100%">
        <infoClasses:InfoWindowLabel styleName="balloonTitle" text="{data.FACILITY}" width="100%"/>
  <mx:Label text="{data.ADDRESS}" />
  <mx:Label text="{data.CITY}, {data.STATE},   {data.ZIP}"/>  

             <mx:Label includeInLayout="{data.PHONE1 != ''? true:false}"
  visible="{data.PHONE1 != ''? true:false}" text="Phone:  {data.PHONE1}"/>
    
             <mx:Label includeInLayout="{data.PHONE2 != ''? true:false}"
  visible="{data.PHONE2 != ''? true:false}"
  text="Phone:  {data.PHONE2}"/>

  <!-- this is the section that is failing ... --> 
  <mx:Label includeInLayout="{(data.PHONE1 != ''? true:false) && (data.PHONE2 !== ''? true:false)}"
  visible="{(data.PHONE1 != ''? true:false) && (data.PHONE2 !== ''? true:false)}"
   text="Phone:  {data.PHONE3_FB}"/>
     
  <mx:Label includeInLayout="{data.DAYS != ''? true:false}"
   visible="{data.DAYS != ''? true:false}"
   text="---------------------------------------" />   
  <mx:Label includeInLayout="{data.DAYS != ''? true:false}"
   visible="{data.DAYS != ''? true:false}"
   text="{data.DAYS}"/>
  <mx:Label includeInLayout="{data.HOURS != ''? true:false}"
   visible="{data.HOURS != ''? true:false}"
   text="{data.HOURS}"/>
  <mx:Label includeInLayout="{data.CERTIFICATION != ''? true:false}"
   visible="{data.CERTIFICATION != ''? true:false}" text="---------------------------------------" />
  <mx:TextArea width="100%" height="60" includeInLayout="{data.CERTIFICATION != ''? true:false}"
   visible="{data.CERTIFICATION != ''? true:false}"
   text="{data.CERTIFICATION}"/>
  <mx:Label includeInLayout="{data.LOC_CODE != 'CENT'? false:true}"
   visible = "{data.LOC_CODE != 'CENT'? false:true}"
   text="** Location Approximate **"/>
        </mx:VBox>  
  </mx:Component>
Tags (2)
0 Kudos
5 Replies
RobertScheitlin__GISP
MVP Emeritus
Tracy,

You have a syntax issue

(data.PHONE1 != ''? true:false) && (data.PHONE2 !== ''? true:false)
0 Kudos
TracySchloss
Frequent Contributor
Yes I do - thanks for catching that.  Unfortunately I still have an error:
The entity name must immediately follow the '&' in the entity reference.

I'm not sure what "entity name" is, but since data.Phone2 does follow right after the &, that wouldn't seem to be it.
0 Kudos
RobertScheitlin__GISP
MVP Emeritus
Tracy,

    Not sure but I would try

(data.PHONE1 == '') && (data.PHONE2 == '')
0 Kudos
TracySchloss
Frequent Contributor
Not it either.  I decided this wasn't just a ESRI/FLEX issue, but could be an issue with anything that's using data binding.

I searchd Google and found this, which worked:

<mx:Label includeInLayout="{(data.PHONE1 == '' &amp;&amp; data.PHONE2 == '') ? true:false}"
visible="{(data.PHONE1 == '' &amp;&amp; data.PHONE2 == '') ? true:false}"
text="Phone:  {data.PHONE3_FB}"/>

I wouldn't have thought actually putting in the ampersands that way would work.  What do I know - I'm not a programmer, I just play one when I come to work!
0 Kudos
RobertScheitlin__GISP
MVP Emeritus
Tracy,

   Good to know... Glad you got it working.
0 Kudos