Friday, April 20, 2012

Difference in between different Visualforce Table Tags in Salesforce

Different Table Tags


Apex: dataTable
An HTML table that is defined by iterating over a set of data, displaying information about one item of data per row. The body of the < apex:dataTable > contains one or more column components that specify what information should be displayed for each item of data. The data set can include up to 1,000 items.





 Apex: pageBlockTable
A list of data displayed as a table within either an < apex:pageBlock > or <apex:pageBlockSection > component, similar to a related list or list view in a standard Salesforce page. Like an < apex:dataTable >, an < apex:pageBlockTable > is defined by iterating over a set of data, displaying information about one item of data per row. The set of data can contain up to 1,000 items.The body of the < apex:pageBlockTable > contains one or more column components that specify what information should be displayed for each item of data, similar to a table. Unlike the < apex:dataTable > component, the default styling for < apex:pageBlockTable > matches standard Salesforce styles. Any additional styles specified with < apex:pageBlockTable > attributes are appended to the standard Salesforce styles.

 

Apex: repeat
This tag is used as for loop(for list) in apex. You can iterate a list.




Now Difference:--

1. By using <apex:repeat> we can't get proper alignments,just it displays data,but in <apex:dataTable> we can get columns wise alignment data.

2.In <apex:repeat> there is no JavaScript events like onmouseover, onclick..........but they are available in <apex:dataTable>.

3. Main Difference Between <data:table> and <apex:pageBlockTable> is,Unlike the  <apex:dataTable > component, the default styling for < apex:pageBlockTable > matches standard Salesforce styles. Any additional styles specified with 
< apex:pageBlockTable > attributes are appended to the standard Salesforce styles.

Summary

PageBlockTable:
-> Pageblocktable should be inside of <apex:pageblock> or <apex:pageblocksection>
-> <apex:pageblocktable> has a required attribute called "value"
-> It uses the standard salesforce page styles
-> Column headers will be displayed automatically

DataTable:
-> No need to write inside <apex:pageblock> or <apex:pageblocksection>
-> There is no required value
-> The data can be displayed using custom styles
-> We need to specify column headers explicitly

Repeat:
-> There is no proper allignment of data in repeat as compared with datatable

 


4 comments:

  1. Hi Abhinav,

    I want to get header labels of columns for my Table which I design in my page with help of dataTable tag How can i get this, Thanks

    ReplyDelete
  2. Use HTML for this purpose tr and td are there for your help.

    ReplyDelete
  3. Really Useful for Beginners.

    ReplyDelete