View

Wednesday, May 1, 2013

Apex Code : Data Table.............



Page:
=====
<apex:page controller="dataTableCon" id="thePage">

        <apex:dataTable border="1" bgcolor="Red" align="Center"  value="{!accounts}" var="account" id="theTable" rowClasses="odd,even"

                        styleClass="tableClass">

                <apex:facet name="caption" >table caption</apex:facet>

                <apex:facet name="header">table header</apex:facet>

                <apex:facet name="footer">table footer</apex:facet>

                <apex:column >

                        <apex:facet name="header">Name</apex:facet>

                        <apex:facet name="footer">column footer</apex:facet>

                        <apex:outputText value="{!account.name}"/>

                </apex:column>

                <apex:column >

                        <apex:facet name="header">Owner</apex:facet>

                        <apex:facet name="footer">column footer</apex:facet>

                        <apex:outputText value="{!account.owner.name}"/>

                </apex:column>
                 <apex:column >

                        <apex:facet name="header">Billing Country</apex:facet>

                        <apex:facet name="footer">column footer</apex:facet>

                        <apex:outputText value="{!account.BillingCountry}"/>

                </apex:column>

        </apex:dataTable>

</apex:page>


Controller:
----------
public class dataTableCon
{                    
        List<Account> accounts;
        public List<Account> getAccounts()
        {
                if(accounts == null) accounts = [Select a.BillingCountry, a.Id, a.Name, a.OwnerId, a.Owner.Name, a.Phone from Account a];
                return accounts;
        }
}

No comments:

Post a Comment

Share your Comments .............