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

visualforce Page - Sort Columns
Hello, I have a table in my visualforce page and I need to sort on some column like this:
<apex:column >
<apex:facet name="header" >
<apex:commandLink action="{!empty}">
<apex:outputText value="Type d'inscription" />
<apex:outputText escape="false" rendered="{!sortBy=='Type d\'inscription'&&sortDir=='ASC'}">
<img src="/s.gif" alt="Sorted Ascending" class="sortAsc" title="Sorted Ascending" />
</apex:outputText>
<apex:outputText escape="false" rendered="{!sortBy=='Type d\'inscription'&&sortDir=='DESC'}">
<img src="/s.gif" alt="Sorted Descending" class="sortDesc" title="Sorted Descending" />
</apex:outputText>
<apex:param value="Type d'inscription" name="column" assignTo="{!sortBy}" />
<apex:param value="{!IF(sortDir=='ASC'&&sortBy=='Type d\'inscription', 'DESC', 'ASC')}" name="direction" assignTo="{!sortDir}" />
</apex:commandLink>
</apex:facet>
<apex:outputText value="{!cmber.campMember.Type_d_inscription__c}" rendered="{!cmber.campMember.Type_d_inscription__c != null}"/>
<apex:outputText value="-" rendered="{!cmber.campMember.Type_d_inscription__c == null}"/>
</apex:column>
When I try to sort, the number of columns decreases( juste 3 lines appears from 10 lines)
Can u help me
<apex:column >
<apex:facet name="header" >
<apex:commandLink action="{!empty}">
<apex:outputText value="Type d'inscription" />
<apex:outputText escape="false" rendered="{!sortBy=='Type d\'inscription'&&sortDir=='ASC'}">
<img src="/s.gif" alt="Sorted Ascending" class="sortAsc" title="Sorted Ascending" />
</apex:outputText>
<apex:outputText escape="false" rendered="{!sortBy=='Type d\'inscription'&&sortDir=='DESC'}">
<img src="/s.gif" alt="Sorted Descending" class="sortDesc" title="Sorted Descending" />
</apex:outputText>
<apex:param value="Type d'inscription" name="column" assignTo="{!sortBy}" />
<apex:param value="{!IF(sortDir=='ASC'&&sortBy=='Type d\'inscription', 'DESC', 'ASC')}" name="direction" assignTo="{!sortDir}" />
</apex:commandLink>
</apex:facet>
<apex:outputText value="{!cmber.campMember.Type_d_inscription__c}" rendered="{!cmber.campMember.Type_d_inscription__c != null}"/>
<apex:outputText value="-" rendered="{!cmber.campMember.Type_d_inscription__c == null}"/>
</apex:column>
When I try to sort, the number of columns decreases( juste 3 lines appears from 10 lines)
Can u help me
Please find thsi blog where Srini has explained with the example.
http://sfdcsrini.blogspot.com/2014/09/sorting-tables-in-visualforce.html
Easiest way would be using Jquery if you are familir.
Regards,
Avishek Nanda
Thank you for your response, but in my case, I want to sort columns when I clic on the name of the column.
I have 10, columns and this problem only appears with 2 columns (picklist fields)