How to Use apex:dataTable in Visualforce page?

<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.


This tag supports following attributes:

Attribute

Description

align
The position of the rendered HTML table with respect to the page. Possible values include "left", "center", or "right". If left unspecified, this value defaults to "left".
bgcolor
The background color of the rendered HTML table.
border
The width of the frame around the rendered HTML table, in pixels.
captionClass
The style class used to display the caption for the rendered HTML table, if a caption facet is specified. This attribute is used primarily to designate which CSS styles are applied when using an external CSS stylesheet.
captionStyle
The style used to display the caption for the rendered HTML table, if a caption facet is specified. This attribute is used primarily for adding inline CSS styles.
cellpadding
The amount of space between the border of each table cell and its contents. If the value of this attribute is a pixel length, all four margins are this distance from the contents. If the value of the attribute is a percentage length, the top and bottom margins are equally separated from the content based on a percentage of the available vertical space, and the left and right margins are equally separated from the content based on a percentage of the available horizontal space.
cellspacing
The amount of space between the border of each table cell and the border of the other cells surrounding it and/or the table's edge. This value must be specified in pixels or percentage.
columnClasses
A comma-separated list of one or more classes associated with the table's columns, used primarily to designate which CSS styles are applied when using an external CSS stylesheet. If more than one class is specified, the classes are applied in a repeating fashion to all columns. For example, if you specify columnClasses="classA, classB", then the first column is styled with classA, the second column is styled with classB, the third column is styled with classA, the fourth column is styled with classB, and so on.
columns
The number of columns in this table.
columnsWidth
A comma-separated list of the widths applied to each table column. Values can be expressed as pixels (for example, columnsWidth="100px, 100px").
dir
The direction in which the generated HTML component should be read. Possible values include "RTL" (right to left) or "LTR" (left to right).
first
The first element in the iteration visibly rendered in the table, where 0 is the index of the first element in the set of data specified by the value attribute. For example, if you did not want to display the first two elements in the set of records specified by the value attribute, set first="2".
footerClass
The style class used to display the footer (bottom row) for the rendered HTML table, if a footer facet is specified. This attribute is used primarily to designate which CSS styles are applied when using an external CSS stylesheet.
frame
The borders drawn for this table. Possible values include "none", "above", "below", "hsides", "vsides", "lhs", "rhs", "box", and "border". If not specified, this value defaults to "border".
headerClass
The style class used to display the header for the rendered HTML table, if a header facet is specified. This attribute is used primarily to designate which CSS styles are applied when using an external CSS stylesheet.
id
An identifier that allows the dataTable component to be referenced by other components in the page.
lang
The base language for the generated HTML output, for example, "en" or "en-US".
onclick
The JavaScript invoked if the onclick event occurs--that is, if the user clicks the data table.
ondblclick
The JavaScript invoked if the ondblclick event occurs--that is, if the user clicks the data table twice.
onkeydown
The JavaScript invoked if the onkeydown event occurs--that is, if the user presses a keyboard key.
onkeypress
The JavaScript invoked if the onkeypress event occurs--that is, if the user presses or holds down a keyboard key.
onkeyup
The JavaScript invoked if the onkeyup event occurs--that is, if the user releases a keyboard key.
onmousedown
The JavaScript invoked if the onmousedown event occurs--that is, if the user clicks a mouse button.
onmousemove
The JavaScript invoked if the onmousemove event occurs--that is, if the user moves the mouse pointer.
onmouseout
The JavaScript invoked if the onmouseout event occurs--that is, if the user moves the mouse pointer away from the data table.
onmouseover
The JavaScript invoked if the onmouseover event occurs--that is, if the user moves the mouse pointer over the data table.
onmouseup
The JavaScript invoked if the onmouseup event occurs--that is, if the user releases the mouse button.
onRowClick
The JavaScript invoked if the onRowClick event occurs--that is, if the user clicks a row in the data table.
onRowDblClick
The JavaScript invoked if the onRowDblClick event occurs--that is, if the user clicks a row in the data table twice.
onRowMouseDown
The JavaScript invoked if the onRowMouseDown event occurs--that is, if the user clicks a mouse button in a row of the data table.
onRowMouseMove
The JavaScript invoked if the onRowMouseMove event occurs--that is, if the user moves the mouse pointer over a row of the data table.
onRowMouseOut
The JavaScript invoked if the onRowMouseOut event occurs--that is, if the user moves the mouse pointer away from a row in the data table.
onRowMouseOver
The JavaScript invoked if the onRowMouseOver event occurs--that is, if the user moves the mouse pointer over a row in the data table.
onRowMouseUp
The JavaScript invoked if the onRowMouseUp event occurs--that is, if the user releases the mouse button over a row in the data table.
rendered
A Boolean value that specifies whether the component is rendered on the page. If not specified, this value defaults to true.
rowClasses
A comma-separated list of one or more classes associated with the table's rows, used primarily to designate which CSS styles are applied when using an external CSS stylesheet. If more than one class is specified, the classes are applied in a repeating fashion to all rows. For example, if you specify columnRows="classA, classB", then the first row is styled with classA, the second row is styled with classB, the third row is styled with classA, the fourth row is styled with classB, and so on.
rows
The number of rows in this table.
rules
The borders drawn between cells in the table. Possible values include "none", "groups", "rows", "cols", and "all". If not specified, this value defaults to "none".
style
The style used to display the dataTable component, used primarily for adding inline CSS styles.
styleClass
The style class used to display the dataTable component, used primarily to designate which CSS styles are applied when using an external CSS stylesheet.
summary
A summary of the table's purpose and structure for Section 508 compliance.
title
The text to display as a tooltip when the user's mouse pointer hovers over this component.
value
The collection of data displayed in the table.
var
The name of the variable that represents one element in the collection of data specified by the value attribute. You can then use this variable to display the element itself in the body of the dataTable component tag.
width
The width of the entire table, expressed either as a relative percentage to the total amount of available horizontal space (for example, width="80%"), or as the number of pixels (for example, width="800px").

Example:
<apex:page standardController="Lead" recordSetVar="Leads">



     <apex:pageBlock title="dataTable">

         <apex:dataTable value="{!Leads}" var="le" width="50%">

             <apex:column value="{!le.name}"  headerValue="Name"/> 

             <apex:column value="{!le.Phone}" headerValue="Phone"/>

             <apex:column value="{!le.Company}" headerValue="Company"/>

         </apex:dataTable> 

     </apex:pageBlock> 

 </apex:page>

The above code generated the below page:


VF_dataTable

COMMENTS

Name

Apex Apex Default Methods Apex Methods Apex_Collections Apps Batch Apex Books CRM eBooks Data Import Wizard Data Management DataLoader Dataloader.io Difference Between Error in Salesforce FAQ's FAQ's-Apex FAQ's-Apps FAQ's-CRM FAQ's-Data loader FAQ's-SOQL & SOSL FAQ'S-Triggers FAQ's-User Profile & Security FAQ's-VF Force.com Explorer Force.com Ide Formulas & Functions Integration Interview Questions Only Latest_Updates Limits&Best Practices Online-Training Reports and Dashboards Salesforce Deployment Salesforce Realtime Examples On Development Salesforce Realtime Task On Admin Salesforce Realtime Tasks Salesforce Realtime Tasks- Apex Salesforce Training Salesforce1 Mobile Sites SOQL Spring'14 Release Triggers User Profile & Security VF Tags VisualForce Winter'14 Release Wizard for Accounts/Contacts Workbench Workflows and Approvals
false
ltr
item
Sfdc Gurukul- All in one place for salesforce and force.com step by step tutorial for beginners: How to Use apex:dataTable in Visualforce page?
How to Use apex:dataTable in Visualforce page?
How to Use apex:dataTable in Visualforce page?,salesforce data table,dataTable ,,dataTable in visualforce page,visualforce page data table,
http://3.bp.blogspot.com/-Irj36hectOs/UfYIDhdDFTI/AAAAAAAAAZU/TCSpkSyH4Zg/s640/VF_dataTable.JPG
http://3.bp.blogspot.com/-Irj36hectOs/UfYIDhdDFTI/AAAAAAAAAZU/TCSpkSyH4Zg/s72-c/VF_dataTable.JPG
Sfdc Gurukul- All in one place for salesforce and force.com step by step tutorial for beginners
http://sfdcgurukul.blogspot.in/2013/07/apexdatatable.html
http://sfdcgurukul.blogspot.in/
http://sfdcgurukul.blogspot.com/
http://sfdcgurukul.blogspot.com/2013/07/apexdatatable.html
true
4199533888133360731
UTF-8
Not found any posts VIEW ALL Readmore Reply Cancel reply Delete By Home PAGES POSTS View All RECOMMENDED FOR YOU LABEL ARCHIVE SEARCH ALL POSTS Not found any post match with your request Back Home Sunday Monday Tuesday Wednesday Thursday Friday Saturday Sun Mon Tue Wed Thu Fri Sat January February March April May June July August September October November December Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec just now 1 minute ago $$1$$ minutes ago 1 hour ago $$1$$ hours ago Yesterday $$1$$ days ago $$1$$ weeks ago more than 5 weeks ago Followers Follow THIS CONTENT IS PREMIUM Please share to unlock Copy All Code Select All Code All codes were copied to your clipboard Can not copy the codes / texts, please press [CTRL]+[C] (or CMD+C with Mac) to copy