You need to sign in to do that
Don't have an account?
![Lukasz Piziak Lukasz Piziak](https://dfc-org-production.my.site.com/img/userprofile/default_profile_45_v2.png)
Default sorting records in pageBlock Table by date field
Hi,
I'm looking for solution of having as default sorting my records in VF column by date field {!item.SCMC__Planned_Completion_Date__c} in ascending order. i will appreciate any help. Thanks.
VF page
<apex:pageBlock rendered="True" title="Production Orders">
<apex:pageBlockSection title="Production Orders to Fill">
<apex:pageBlockTable value="{!objlist}" style="width:1220px" var="item">
<apex:column style="width:100px" headerValue="Production Order No.">
<apex:outputLink value="/{!item.id}" target="_blank">
{!item.Name}
</apex:outputLink>
</apex:column>
<apex:column style="width:100px" value="{!item.Sales_Order_No__c}"/>
<apex:column style="width:100px" value="{!item.Customer__c}" headerValue="Customer Name"/>
<apex:column style="width:200px" value="{!item.Assembly_Name__c}" headerValue="Hose Description"/>
<apex:column style="width:100px" value="{!item.SCMC__Start_Date__c}" headerValue="Production Start Date"/>
<apex:column style="width:100px" value="{!item.SCMC__Planned_Completion_Date__c}" headerValue="Planned Completion Date"/>
<apex:column style="width:100px" value="{!item.SCMC__Production_Status__c}"/>
</apex:pageBlockTable>
</apex:pageBlockSection>
Controller
public class TestExtension {
public List<SCMC__Production_Order__c> objlist{get;set;}
public TestExtension(ApexPages.StandardSetController controller) {
objlist = [SELECT Name, Sales_Order_No__c,Customer__c, Assembly_Name__c, SCMC__Start_Date__c, SCMC__Planned_Completion_Date__c, SCMC__Production_Status__c
FROM SCMC__Production_Order__c Where SCMC__Production_Status__c = 'Pending Pulling All Items'];
}
}
I'm looking for solution of having as default sorting my records in VF column by date field {!item.SCMC__Planned_Completion_Date__c} in ascending order. i will appreciate any help. Thanks.
VF page
<apex:pageBlock rendered="True" title="Production Orders">
<apex:pageBlockSection title="Production Orders to Fill">
<apex:pageBlockTable value="{!objlist}" style="width:1220px" var="item">
<apex:column style="width:100px" headerValue="Production Order No.">
<apex:outputLink value="/{!item.id}" target="_blank">
{!item.Name}
</apex:outputLink>
</apex:column>
<apex:column style="width:100px" value="{!item.Sales_Order_No__c}"/>
<apex:column style="width:100px" value="{!item.Customer__c}" headerValue="Customer Name"/>
<apex:column style="width:200px" value="{!item.Assembly_Name__c}" headerValue="Hose Description"/>
<apex:column style="width:100px" value="{!item.SCMC__Start_Date__c}" headerValue="Production Start Date"/>
<apex:column style="width:100px" value="{!item.SCMC__Planned_Completion_Date__c}" headerValue="Planned Completion Date"/>
<apex:column style="width:100px" value="{!item.SCMC__Production_Status__c}"/>
</apex:pageBlockTable>
</apex:pageBlockSection>
Controller
public class TestExtension {
public List<SCMC__Production_Order__c> objlist{get;set;}
public TestExtension(ApexPages.StandardSetController controller) {
objlist = [SELECT Name, Sales_Order_No__c,Customer__c, Assembly_Name__c, SCMC__Start_Date__c, SCMC__Planned_Completion_Date__c, SCMC__Production_Status__c
FROM SCMC__Production_Order__c Where SCMC__Production_Status__c = 'Pending Pulling All Items'];
}
}
All Answers
Replace your query with this snippt. If this answers your question mark Best Answer it as solution and then hit Like!
Please try the below updated query,
[SELECT Name, Sales_Order_No__c,Customer__c, Assembly_Name__c, SCMC__Start_Date__c, SCMC__Planned_Completion_Date__c, SCMC__Production_Status__c
FROM SCMC__Production_Order__c Where SCMC__Production_Status__c = 'Pending Pulling All Items' ORDER BY SCMC__Planned_Completion_Date__c ASC]
Thanks,
Vinoth
I want to sort table by date field in ascending order .
Any help is appreciated.