You need to sign in to do that
Don't have an account?

Sorting DataTable in Visualforce
Hey everyone,
I have a pretty simple dataTable in Visualforce (see code below), I'm just trying to figure out how to sort by {!b.Balance__c}
I've tried a number of things, but none of them seem to work.
Thanks!!!
<apex:pageBlock >
<apex:dataTable value="{!Contact.Positions__r}" var="b" width="100%" columns="1" columnsWidth="60%,40%">
sortorder = "{!b.Name}"
<apex:column >
<apex:outputText value="{!b.Product__r.Name}"/>
</apex:column>
<apex:column >
<apex:outputText value="{!b.Name}"/>
</apex:column>
<apex:column style="text-align:right" headerClass="CurrencyElement">
<apex:outputField value="{!b.Balance__c}"/>
</apex:column>
</apex:dataTable>
</apex:pageBlock>
I have a pretty simple dataTable in Visualforce (see code below), I'm just trying to figure out how to sort by {!b.Balance__c}
I've tried a number of things, but none of them seem to work.
Thanks!!!
<apex:pageBlock >
<apex:dataTable value="{!Contact.Positions__r}" var="b" width="100%" columns="1" columnsWidth="60%,40%">
sortorder = "{!b.Name}"
<apex:column >
<apex:outputText value="{!b.Product__r.Name}"/>
</apex:column>
<apex:column >
<apex:outputText value="{!b.Name}"/>
</apex:column>
<apex:column style="text-align:right" headerClass="CurrencyElement">
<apex:outputField value="{!b.Balance__c}"/>
</apex:column>
</apex:dataTable>
</apex:pageBlock>
1. For each apex:column, change the code as below. 2. Add the following code
3. Build you query function. You need to change accordinlgy.
All Answers
If not you will have to write a custom controller, check this link that may help you
http://onlysalesforce.blogspot.com/2013/08/custom-sort-feature-in-salesforce-based.html
If it helps,please mark as correct,it may help others.
1. For each apex:column, change the code as below. 2. Add the following code
3. Build you query function. You need to change accordinlgy.