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
Pavan kumar 546Pavan kumar 546 

differences between data table and page block table in reality? give simple examples?

Best Answer chosen by Pavan kumar 546
Amit Chaudhary 8Amit Chaudhary 8
PageBlockTable:
1) PageBlockTable should be define inside pageblock or pageblocksection.
2) PageBlockTable uses standard styles sheets to design a visualpage.
3) It has the  required attribute "value".
4) Column headers  will be displayed automatically. 
5) No need to specify the headers


DataTable:
1) No need to write inside pageblock or pageblocksection.
2) There is no required value.
3) The  data can be displayed using  custom style sheets.
4) we need to specify column headers explicitly.
5) Need to specify the headers

Please check below post for more info.
1) http://www.thephani.com/difference-between-pageblocktabe-datatable-repeat/
2) http://www.infallibletechie.com/2013/04/what-is-difference-between-and.html
 
<apex:page controller="sample" sidebar="false" >
<style type="text/css">
    .outBorder
    {
        border:3px outset black;
    }
    
    .inBorder
    {
        border-top:3px dotted black;
        border-left:3px dotted black;
    }    
</style>
    <apex:pageBlock title="Pageblock Table">
        <apex:pageblockTable value="{!acc}" var="a">
            <apex:column value="{!a.Name}"/>
            <apex:column value="{!a.Name}"/>            
        </apex:pageblockTable>
    </apex:pageBlock>
    
    <apex:pageBlock title="Data Table">
        <apex:dataTable value="{!acc}" var="a" styleClass="outBorder" width="550px">
            <apex:column styleClass="inBorder">
                <apex:facet name="header">Account Name</apex:facet>
                <apex:outputText >{!a.Name}</apex:outputText>
            </apex:column>       
            <apex:column styleClass="inBorder">
                <apex:facet name="header">Account Number</apex:facet>
                <apex:outputText >{!a.AccountNumber}</apex:outputText>
            </apex:column>              
        </apex:dataTable>
    </apex:pageBlock>    
</apex:page>
public with sharing class sample
{

    public List<Account> acc {get;set;}
    public sample()
    {
        acc = [SELECT Name, AccountNumber FROM Account];
    }  
    
}



 

All Answers

Amit Chaudhary 8Amit Chaudhary 8
PageBlockTable:
1) PageBlockTable should be define inside pageblock or pageblocksection.
2) PageBlockTable uses standard styles sheets to design a visualpage.
3) It has the  required attribute "value".
4) Column headers  will be displayed automatically. 
5) No need to specify the headers


DataTable:
1) No need to write inside pageblock or pageblocksection.
2) There is no required value.
3) The  data can be displayed using  custom style sheets.
4) we need to specify column headers explicitly.
5) Need to specify the headers

Please check below post for more info.
1) http://www.thephani.com/difference-between-pageblocktabe-datatable-repeat/
2) http://www.infallibletechie.com/2013/04/what-is-difference-between-and.html
 
<apex:page controller="sample" sidebar="false" >
<style type="text/css">
    .outBorder
    {
        border:3px outset black;
    }
    
    .inBorder
    {
        border-top:3px dotted black;
        border-left:3px dotted black;
    }    
</style>
    <apex:pageBlock title="Pageblock Table">
        <apex:pageblockTable value="{!acc}" var="a">
            <apex:column value="{!a.Name}"/>
            <apex:column value="{!a.Name}"/>            
        </apex:pageblockTable>
    </apex:pageBlock>
    
    <apex:pageBlock title="Data Table">
        <apex:dataTable value="{!acc}" var="a" styleClass="outBorder" width="550px">
            <apex:column styleClass="inBorder">
                <apex:facet name="header">Account Name</apex:facet>
                <apex:outputText >{!a.Name}</apex:outputText>
            </apex:column>       
            <apex:column styleClass="inBorder">
                <apex:facet name="header">Account Number</apex:facet>
                <apex:outputText >{!a.AccountNumber}</apex:outputText>
            </apex:column>              
        </apex:dataTable>
    </apex:pageBlock>    
</apex:page>
public with sharing class sample
{

    public List<Account> acc {get;set;}
    public sample()
    {
        acc = [SELECT Name, AccountNumber FROM Account];
    }  
    
}



 
This was selected as the best answer
Pavan kumar 546Pavan kumar 546
thanq