Skip to main content
Hello, 

I am trying to create a page where I can dynamically group querry results, and am using the code in this blog post as a template: template (http://blog.jeffdouglas.com/2011/03/02/dynamically-group-display-query-results/)

The difference is that I am trying to do this with a custom object instead of a standard object. 

Here is my controller: 

 

public with sharing class DisplaySectionsController {

public List<PI_Vendor__c> vendors {get;set;}

public String[] states {get;set;}

public void load() {

vendors = [Select ID, Name, State__c from PI_Vendor__c WHERE State__c IN ('DE','PA','MD')];

Set<String> stateSet = new Set<String>();

for (PI_Vendor__c v : vendors)

stateSet.add(v.State__c);

states = new String[stateSet.size()];

Integer i = 0;

for (String state : stateSet) {

states[i] = state;

i++;

}

}

}

and here is my vf page: 

 

<apex:page controller="DisplaySectionsController" action="{!load}" sidebar="false">

<apex:sectionHeader title="My Sample Display Page" subtitle="Group by States"

description="This page shows how you can dynamically group results by field value."/>

<apex:repeat value="{!states}" var="state">

<apex:pageBlock title="{!state}">

<apex:repeat value="{!vendors}" var="vnd">

<apex:outputPanel rendered="{!IF(state=vendors.State__c,true,false)}">

{!vnd.Name} - {!vnd.State__c}<br/>

</apex:outputPanel>

</apex:repeat>

</apex:pageBlock>

</apex:repeat>

</apex:page>

but I am getting the following error: 

 

Error: Unknown property 'VisualforceArrayList.State__c'

What can I do to make this work with a custom object?  And more importantly, where am I currently going wrong? 

Thanks in advance!

John

 
4 respuestas
  1. 23 abr 2015, 18:46
    I forgot to initialize the Map. Add this before your for loop (after the stateSet initilization)

    vendorMap = new Map<String, List<PI_Vendor__c> >();

     
0/9000