You need to sign in to do that
Don't have an account?
Admin User 10568
Creating Standard Controller Extension to Sort List Ascending
Hi,
Hopeing someone can help me here.
I would like to filter results in a pageBlockTable in ascending order.
I've created a standard controller extension:
public with sharing class ProjectONSExtension
{
private final Id acctId;
public List<REPRO__Project__c> oncs { get; set; }
public ProjectONSExtension(ApexPages.StandardController stdController)
{
acctId = stdController.getId();
oncs = Database.query('SELECT Name,REPRO__Street__c, REPRO__City__c, (SELECT Id,name,Property_Level__c,Price_List_Property_Name__c,REPRO__Type__c,REPRO__Bdr__c,REPRO__Bth__c,REPRO__Study__c,REPRO__Internal_Size__c,REPRO__External_Size__c,REPRO__Car__c,REPRO__List_Price__c,REPRO__Status__c from REPRO__Properties__r where REPRO__Project__c =:acctId order by Price_List_Property_Name__c )' +
' FROM REPRO__Project__c '
);
}
}
It runs without an error. But it didn't order the pageBlockTable results in ascending order. Boo! Any thoughts?
Here is the visual page for reference:
<apex:page standardController="REPRO__Project__c" extensions="ProjectONSExtension" renderAs="pdf" showHeader="false" sidebar="false" >
<apex:pageBlock >
<h1 style= "text-align: center;">{!REPRO__Project__c.name}</h1>
<p style= "text-align: center;">{!REPRO__Project__c.REPRO__Street__c}, {!REPRO__Project__c.REPRO__City__c} <br/> Price List as of {! TODAY()} </p>
<apex:pageBlockTable value="{!REPRO__Project__c.REPRO__Properties__r}" var="custom" align="center" cellpadding="1" border="2" style="font-weight: bold; text-align: center; ">
<apex:column value="{!custom.Property_Level__c}" style="padding: 10px;order-bottom: 1px solid #ddd;border: 1px solid black; text-align: center; " />
<apex:column value="{!custom.Price_List_Property_Name__c}" style="padding: 10px;order-bottom: 1px solid #ddd;border: 1px solid black; text-align: center; " />
<apex:column value="{!custom.REPRO__Type__c}" style="padding: 10px;order-bottom: 1px solid #ddd;border: 1px solid black; text-align: center; " />
<apex:column value="{!custom.REPRO__Bdr__c}" style="padding: 10px;order-bottom: 1px solid #ddd;border: 1px solid black; text-align: center; " />
<apex:column value="{!custom.REPRO__Bth__c}" style="padding: 10px;order-bottom: 1px solid #ddd;border: 1px solid black; text-align: center; " />
<apex:column value="{!custom.REPRO__Study__c}" style="padding: 10px;order-bottom: 1px solid #ddd;border: 1px solid black; text-align: center; " />
<apex:column value="{!custom.REPRO__Internal_Size__c}" style="padding: 10px;order-bottom: 1px solid #ddd;border: 1px solid black; text-align: center; " />
<apex:column value="{!custom.REPRO__External_Size__c}" style="padding: 10px;order-bottom: 1px solid #ddd;border: 1px solid black; text-align: center; " />
<apex:column value="{!custom.REPRO__Car__c}" style="padding: 10px;order-bottom: 1px solid #ddd;border: 1px solid black; text-align: center; " />
<apex:column value="{!custom.REPRO__List_Price__c}" style="padding: 10px;order-bottom: 1px solid #ddd;border: 1px solid black; text-align: center; " />
<apex:column value="{!custom.REPRO__Status__c}" style="padding: 10px;order-bottom: 1px solid #ddd;border: 1px solid black; text-align: center; " />
</apex:pageBlockTable>
Any help would be greatly appreciated :)
Hopeing someone can help me here.
I would like to filter results in a pageBlockTable in ascending order.
I've created a standard controller extension:
public with sharing class ProjectONSExtension
{
private final Id acctId;
public List<REPRO__Project__c> oncs { get; set; }
public ProjectONSExtension(ApexPages.StandardController stdController)
{
acctId = stdController.getId();
oncs = Database.query('SELECT Name,REPRO__Street__c, REPRO__City__c, (SELECT Id,name,Property_Level__c,Price_List_Property_Name__c,REPRO__Type__c,REPRO__Bdr__c,REPRO__Bth__c,REPRO__Study__c,REPRO__Internal_Size__c,REPRO__External_Size__c,REPRO__Car__c,REPRO__List_Price__c,REPRO__Status__c from REPRO__Properties__r where REPRO__Project__c =:acctId order by Price_List_Property_Name__c )' +
' FROM REPRO__Project__c '
);
}
}
It runs without an error. But it didn't order the pageBlockTable results in ascending order. Boo! Any thoughts?
Here is the visual page for reference:
<apex:page standardController="REPRO__Project__c" extensions="ProjectONSExtension" renderAs="pdf" showHeader="false" sidebar="false" >
<apex:pageBlock >
<h1 style= "text-align: center;">{!REPRO__Project__c.name}</h1>
<p style= "text-align: center;">{!REPRO__Project__c.REPRO__Street__c}, {!REPRO__Project__c.REPRO__City__c} <br/> Price List as of {! TODAY()} </p>
<apex:pageBlockTable value="{!REPRO__Project__c.REPRO__Properties__r}" var="custom" align="center" cellpadding="1" border="2" style="font-weight: bold; text-align: center; ">
<apex:column value="{!custom.Property_Level__c}" style="padding: 10px;order-bottom: 1px solid #ddd;border: 1px solid black; text-align: center; " />
<apex:column value="{!custom.Price_List_Property_Name__c}" style="padding: 10px;order-bottom: 1px solid #ddd;border: 1px solid black; text-align: center; " />
<apex:column value="{!custom.REPRO__Type__c}" style="padding: 10px;order-bottom: 1px solid #ddd;border: 1px solid black; text-align: center; " />
<apex:column value="{!custom.REPRO__Bdr__c}" style="padding: 10px;order-bottom: 1px solid #ddd;border: 1px solid black; text-align: center; " />
<apex:column value="{!custom.REPRO__Bth__c}" style="padding: 10px;order-bottom: 1px solid #ddd;border: 1px solid black; text-align: center; " />
<apex:column value="{!custom.REPRO__Study__c}" style="padding: 10px;order-bottom: 1px solid #ddd;border: 1px solid black; text-align: center; " />
<apex:column value="{!custom.REPRO__Internal_Size__c}" style="padding: 10px;order-bottom: 1px solid #ddd;border: 1px solid black; text-align: center; " />
<apex:column value="{!custom.REPRO__External_Size__c}" style="padding: 10px;order-bottom: 1px solid #ddd;border: 1px solid black; text-align: center; " />
<apex:column value="{!custom.REPRO__Car__c}" style="padding: 10px;order-bottom: 1px solid #ddd;border: 1px solid black; text-align: center; " />
<apex:column value="{!custom.REPRO__List_Price__c}" style="padding: 10px;order-bottom: 1px solid #ddd;border: 1px solid black; text-align: center; " />
<apex:column value="{!custom.REPRO__Status__c}" style="padding: 10px;order-bottom: 1px solid #ddd;border: 1px solid black; text-align: center; " />
</apex:pageBlockTable>
Any help would be greatly appreciated :)
>> https://developer.salesforce.com/forums/?id=906F0000000BVX2IAO
Let me know if it helps you and close your query by marking it as solved so that it can help others in the future.
Thanks.
All Answers
>> https://help.salesforce.com/articleView?id=000328724&type=1&mode=1
I found the above link to the help article that has an implementation of showing records in a sorting order can you try checking the above link once.
I am adding the snippet present for quick reference :
Let me know if it helps you and close your query by marking it as solved so that it can help others in the future.
Thanks.
Thanks for the URL and the explanation. Super helpful for creating filters on a table and a custom controller.
I have a requirement for using a standard controller and an extension to perform the ascending order request. The page will be used as part of a custom button on the object.
I need help to understand why my code has no error yet doesn't pass the ascending request in the controller extension.
It would be amazing if you or someone could help me understand what changes need to happen to make it happen.
Many thanks :)
>> https://developer.salesforce.com/forums/?id=906F0000000BVX2IAO
Let me know if it helps you and close your query by marking it as solved so that it can help others in the future.
Thanks.
Thanks for your thoughtful sharing.
This was okay for a reference. >> https://developer.salesforce.com/forums/?id=906F0000000BVX2IAO
I worked it out with trial and error.
Two main issues/changes.
One. I was treating the SOQL as if I needed to traverse child to parent and same with creating the method. Updated to reference the object extension and the SOQL to reflect this. It works now. Two. Within the visual page I needed to reference the method in the table.
It works now.
Many thanks for helping with the reference URL.
Do you know how can I use this code you sent as an extension of a standard controller?