function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
AkiraDioAkiraDio 

Hide table

 

Good day!

I have a table:

<Apex: DataTable value = "{! MyActGoalsDescList}" var = "GP" rowClasses = "odd, even" styleClass = "bhpb-act bhpb-base bot-margin row-highlight" columnsWidth = "100px, 500px, 150px, 150px , 150px ">
    
<apex:column style="text-align:" headervalue="{!$Label.Goal_set_in}">
    
<apex:outputText value="{0,date,MMMM','yyyy}">
    
<apex:param value="{!GT.CreatedDate}" />
</ Apex: outputText>
    
</ Apex: column>
<apex:column style="text-align:" headervalue="{!$Label.Due_Date}">
<apex:outputText value="{0,date,MM'/'dd'/'yyyy}">
    
<apex:param value="{!GT.Targeted_Due_Date__c}" />
</ Apex: outputText>
</ Apex: column>
<apex:column style="text-align:" headervalue="{!$Label.Status}" value="{!GT.Status__c}" />
</ Apex: DataTable>

 



The source for this table:

public List<Action_Goal__c> MyActGoalsDescList
   {
      get
      {
          List<Action_Goal__c> MyActGoalsDescList = new List<Action_Goal__c>();
          if ((MyGoalType != null) && (MyGoalType !=''))
          {
//              Date MyDate = getStartDate();
              Map<id,Action_Goal__c> aMap = new Map<id,Action_Goal__c>(
                                 [select Goal_Description__c ,id, Goal_Type__c, Targeted_Due_Date__c, Name, Status__c, CreatedDate
                                    From Action_Goal__c
                                    Where ToLabel(Goal_Type__c) =:MyGoalType
                                       AND ((CALENDAR_Year(Targeted_Due_Date__c)= :MyYear AND CALENDAR_Month(Targeted_Due_Date__c)= :MyMonth)
                                            OR ( Status__c !=:BusinessPlanUtil.Completed ) )
                                       AND CreatedById =:MyUserID
                                  ]);
                
              if (aMap.isEmpty())
              {
                Action_Goal__c tmp = new Action_Goal__c();
                tmp.Goal_Description__c =' ';
                MyActGoalsDescList.add(tmp);
              }
              else
              {
                MyActGoalsDescList = aMap.values() ;
                MyActGoals= new List<MyActGoals__c> ();
                Set<id> whatIDSet = aMap.keySet() ;
                MyActGoals = getMyActGoalsList(whatIDSet);
              }
          }
         return MyActGoalsDescList;
    }
    set;
   }

How do I make sure that if MyActGoalsDescList empty table does not render?

 

 

 

Best Answer chosen by Admin (Salesforce Developers) 
PrachiPrachi

Hi,

 

You can use the 'rendered' attribute of apex:dataTable. 

eg: <apex: DataTable value = "{! MyActGoalsDescList}" var = "GP" rowClasses = "odd, even" styleClass = "bhpb-act bhpb-base bot-margin rendered={!MyActGoalsDescList.size>0}>

 

The rendered attribute will display the table only when the condition within the expression tag evaluates to true. i.e if your list size > 0.

 

All Answers

PrachiPrachi

Hi,

 

You can use the 'rendered' attribute of apex:dataTable. 

eg: <apex: DataTable value = "{! MyActGoalsDescList}" var = "GP" rowClasses = "odd, even" styleClass = "bhpb-act bhpb-base bot-margin rendered={!MyActGoalsDescList.size>0}>

 

The rendered attribute will display the table only when the condition within the expression tag evaluates to true. i.e if your list size > 0.

 

This was selected as the best answer
AkiraDioAkiraDio

Спасибо!!!