+ Start a Discussion
srinivasusrinivasu 

how to render a VF page with or without records in OpenActivities, not using <apex:relatedList>?

Hi,

 

I have a requirement like this.

Screen 1: i have to display open activities records if records exit

Screen 2: i have to show the text :"No records to display" if records do not exist.

 

I am using below code but it is not giving desired results, can i do it without using controller.

 

 <apex:page standardController="Account" extensions="BusinessPrintController"
standardStylesheets="true"  sidebar="false" showheader="false">

<apex:pageBlock title="Open Activities">
          <apex:pageBlockTable value="{!Account.OpenActivities}" var="item" rendered="{!IF(ISNULL(Account.OpenActivities),false,true)}">
       <!--     <apex:pageBlockTable value="{!Account.OpenActivities}" var="item" rendered="{!IF(item>0,false,true)}"> -->
            <!-- <apex:pageBlockTable value="{!Account.OpenActivities}" var="item">  -->
            <apex:column width="16%" value="{!item.Subject}"/>
            <apex:column width="10%" value="{!item.IsTask}"/>
            <apex:column width="20%" value="{!item.ActivityDate}"/>
            <!--<apex:column value="{!NULLVALUE(item.Status,'-')}"/>-->
            <apex:column width="20%" value="{!item.Status}"/>
            <!-- <apex:column value="{!NULLVALUE(item.Priority,'-')}"/> -->
            <apex:column width="15%" value="{!item.Priority}"/>
            <apex:column width="40%" value="{!item.OwnerId}"/>    
        </apex:pageBlockTable>
                  
          <apex:dataTable value="{!Account.OpenActivities}" var="item" rendered="{!IF(ISNULL(Account.OpenActivities),true,false)}"> hhh
          <apex:column headervalue="No Records to display"></apex:column>
        </apex:dataTable>
                              

        </apex:pageblock>

Navatar_DbSupNavatar_DbSup

Hi,

You can try the size method of the list in the rerender attribute of the data table

 

For example try the below code

 

Vf page

<apex:page standardController="Account" extensions="BusinessPrintController" >

 

<apex:pageBlock title="Open Activities">

  <apex:pageBlockTable value="{!task1}" var="task" rendered="{!task1.size>0}" >

    <apex:column >{!task.subject}</apex:column>

 

  </apex:pageBlockTable>

 

</apex:pageblock>

</apex:page>

 

Apex controller

 

public class BusinessPrintController

{

    public list<task>task1{get;set;}

 

   

 

    public BusinessPrintController(ApexPages.StandardController controller)

    {

 

        task1=new list<task>();

        task1=[select subject,status,Priority,ActivityDate from task];

             

    }   

 

}

 

Did this answer your question? If not, let me know what didn't work, or if so, please mark it solved.