You need to sign in to do that
Don't have an account?
PageBlockTable Sort Controller
I'm a newbie to controllers and need some help sorting a pageblocktable.
Custom Object: Apartment__c
Related List: Unit__c
Result: Sort Units by Nickname__c
Simple VF Page:
<apex:page sidebar="false" showHeader="false" cache="false" standardController="Apartment__c" extensions="sortExtention" >
<apex:form >
<apex:pageBlock >
<apex:pageBlockTable value="{!sortExtension}" var="item">
<apex:column value="{!item.ID}" />
<apex:column value="{!item.Unit_Number__c}" />
<apex:column value="{!item.Nickname__c}" />
<apex:column value="{!item.Available__c}" />
<apex:column value="{!item.Bedrooms__c}" />
<apex:column value="{!item.Bathrooms__c}" />
</apex:pageBlockTable>
</apex:pageBlock>
</apex:form>
</apex:page>
Controller
public class sortExtension{
public Apartment__c Apt;
public ApexPages.StandardController controller {get; set;}
public List<Unit__c> units; public sortExtension (ApexPages.Standardcontroller c)
{
this.controller = c; Apt = (Apartment__c)Controller.getRecord(); }
public Unit__c [ ] getUnitList()
units = ([Select ID,Unit_Number__c,Available__c,Bathrooms__c,Bedrooms__c,Nickname__c from Unit__c Where Apartment__c.Unit__r = :TC.id ORDER BY Nickname__c]);
return units;}
ERROR: Compile Error: unexpected token: 'units' at line 9 column 7
Thank you in advance for your help!
All Answers
How do I close it? When I say I'm a newbie...I mean this is my first controller. ;-)
{ // this is the opening curly brace
all your logic
return unitlist;
} // this is closing curly brace
Got It! The controller saved but when I try to enter the logic into the VF page I get an error:
Error: Unknown property 'Apartment__cStandardController.getUnitList'
I know I'm close.....is there a smiley for hitting your head up a wall?
VF Page:
<apex:page sidebar="false" showHeader="false" cache="false" standardController="Apartment__c" extensions="sortExtension" >
<apex:form >
<apex:pageBlock >
<apex:pageBlockTable value="{!getUnitList}" var="item">
<apex:column value="{!item.ID}" />
<apex:column value="{!item.Unit_Number__c}" />
<apex:column value="{!item.Nickname__c}" />
<apex:column value="{!item.Available__c}" />
<apex:column value="{!item.Bedrooms__c}" />
<apex:column value="{!item.Bathrooms__c}" />
</apex:pageBlockTable>
</apex:pageBlock>
</apex:form>
</apex:page>
Controller:
public class sortExtension{
public Apartment__c Apt;
public ApexPages.StandardController controller {get; set;}
public List<Unit__c> units; public sortExtension (ApexPages.Standardcontroller c)
{
this.controller = c; Apt = (Apartment__c)Controller.getRecord();}
public Unit__c [ ] getUnitList()
{units = ([Select ID,Unit_Number__c,Available__c,Bathrooms__c,Bedrooms__c,Nickname__c from Unit__c Where Apartment__c = :Apt.id ORDER BY Nickname__c]);
return units;}
}
Thank you in advance!
THAT WAS IT!! {!UnitList}
Thank you so much!! I really appreciate the help.