You need to sign in to do that
Don't have an account?
Lisa Horne
Default Sort Visualforce table
I created a VF page for a custom object and would like to have the column header "Certification Year" sorted by default in decending order.
Is there an easy way to do this without a controller? I'm new to coding and am not familiar with this. Or can someone help me with getting it done?
This is the code I have for the visualforce page:
<apex:page standardController="Account">
You are viewing the {!account.name} account.
<apex:pageBlock title="ONS's">
<apex:pageBlockTable value="{!account.ONC_s__r}" var="onc">
<apex:column value="{!onc.Name}"/>
<apex:column value="{!onc.Owner.name}"/>
<apex:column value="{!onc.Certification_Year__c}" />
<apex:column value="{!onc.Practice_Setting__c}"/>
</apex:pageBlockTable>
</apex:pageBlock>
</apex:page>
Is there an easy way to do this without a controller? I'm new to coding and am not familiar with this. Or can someone help me with getting it done?
This is the code I have for the visualforce page:
<apex:page standardController="Account">
You are viewing the {!account.name} account.
<apex:pageBlock title="ONS's">
<apex:pageBlockTable value="{!account.ONC_s__r}" var="onc">
<apex:column value="{!onc.Name}"/>
<apex:column value="{!onc.Owner.name}"/>
<apex:column value="{!onc.Certification_Year__c}" />
<apex:column value="{!onc.Practice_Setting__c}"/>
</apex:pageBlockTable>
</apex:pageBlock>
</apex:page>
The only way I know to do this is with a controller extension.
Create a new Apex Class like this:
In the above query I'm assuming the name of your lookup field to the Account is "Account__c". If that's not correct just replace it with the API name of the Account lookup field.
Your Visualforce page will look like this:
You'll also need a test class for the extension:
Hope that helps,
Clint
All Answers
The only way I know to do this is with a controller extension.
Create a new Apex Class like this:
In the above query I'm assuming the name of your lookup field to the Account is "Account__c". If that's not correct just replace it with the API name of the Account lookup field.
Your Visualforce page will look like this:
You'll also need a test class for the extension:
Hope that helps,
Clint
On Simple example you see on below blog
http://bobbuzzard.blogspot.in/2014/09/sorting-visualforce-tables-with.html
http://salesforcesource.blogspot.in/2008/11/adding-sorting-capability-to.html
Please let us know if this will help you
Thanks
Amit Chaudhary
Here is my visualforce page:
Here is my controller:
Here is the test...I need the column "Asset Name" to be sorted.
Feel free to send me your contact details at clint@textey.io. I can help you out.
Clint