Take the 2-minute tour ×
Salesforce Stack Exchange is a question and answer site for Salesforce administrators, implementation experts, developers and anybody in-between. It's 100% free, no registration required.

I'm having issues with displaying more than 20 records from a Custom Setting on my visualforce page. I've tried using apex:repeat, apex:pageblocktable, apex:datatable with no luck.

Best, Eric

<apex:page standardController="UserQueueSettings__c" sidebar="false" recordSetVar="UserQueueSettings__c" >
    <apex:form >
        <apex:pageBlock >
            <apex:pageMessages />
            <apex:pageBlockButtons >
                <apex:commandButton value="Save" action="{!save}"/>
            </apex:pageBlockButtons>
            <apex:repeat value="{!UserQueueSettings__c}" var="block" rows="1000">
                <apex:datatable value="{!block}" var="ES" id="memberTable" rows="1000">


                    <apex:column headerValue="Name">
                        <apex:inputField value="{!ES.SetupOwnerId}"/>

    <!--                    <apex:facet name="header">TEST</apex:facet>
                    <apex:inputField value="{!ES.Priority_1__c}" 
                                     required="false"/>

                        <apex:outputField value="{!ES.Priority_1__c}" />
    -->                 

                    </apex:column>
                    <apex:column headerValue="Priority 1">
                        <apex:inputField value="{!ES.Priority_1__c}"/>
                    </apex:column>
                    <apex:column headerValue="Priority 2">
                        <apex:inputField value="{!ES.Priority_2__c}"/>
                    </apex:column>
                    <apex:column headerValue="Priority 3">
                        <apex:inputField value="{!ES.Priority_3__c}"/>
                    </apex:column>

                </apex:datatable>
            </apex:repeat>  
share|improve this question
add comment

2 Answers 2

up vote 4 down vote accepted

I suspect using the standard controller on a custom setting, or perhaps even the recordSetVar is causing the issue.

My suggestion would be to create a simple visualforce controller and either query for the custom setting record or use the getAll() method, and then iterate over that list in your Visualforce page.

Controller:

public class MySettingsCtrl {
    public List<MySettings__c> settings {get; private set;}

    public MySettingsCtrl(){
        //You're probably going to have to query for the Custom Setting records if you want 
        //all hierarchy instances.  Otherwise, you could use the cached records with getAll() or get Instance
        //More info on custom setting methods here: http://www.salesforce.com/us/developer/docs/apexcode/Content/apex_methods_system_custom_settings.htm
        settings = [Select SetupOwnerId,Priority_1__c,Priority_2__c,Priority_3__c From UserQueueSettings__c];
    }
}

And your visualforce would be updated to look like:

<apex:page controller="MySettingsCtrl" sidebar="false">
<apex:form >
    <apex:pageBlock >
        <apex:pageMessages />
        <apex:pageBlockButtons >
            <apex:commandButton value="Save" action="{!save}"/>
        </apex:pageBlockButtons>
        <!--<apex:repeat value="{!settings}" var="block" rows="1000">-->
            <apex:datatable value="{!settings}" var="ES" id="memberTable" rows="1000">


                <apex:column headerValue="Name">
                    <apex:inputField value="{!ES.SetupOwnerId}"/>

<!--                    <apex:facet name="header">TEST</apex:facet>
                <apex:inputField value="{!ES.Priority_1__c}" 
                                 required="false"/>

                    <apex:outputField value="{!ES.Priority_1__c}" />
-->                 

                </apex:column>
                <apex:column headerValue="Priority 1">
                    <apex:inputField value="{!ES.Priority_1__c}"/>
                </apex:column>
                <apex:column headerValue="Priority 2">
                    <apex:inputField value="{!ES.Priority_2__c}"/>
                </apex:column>
                <apex:column headerValue="Priority 3">
                    <apex:inputField value="{!ES.Priority_3__c}"/>
                </apex:column>

            </apex:datatable>
        <!--</apex:repeat>-->
    </apex:pageblock>  
    </apex:form>
</apex:page>
share|improve this answer
    
Thanks James! I want to go with a getall(). would i need a return on my method ? I'm having issues constructing the map or list. Kinda Lost.. :/ –  Eric Luu Feb 11 at 0:32
    
Are you using a hierarchy or list custom setting? From the Visualforce it looks like a hierarchy setting, but need to confirm before I can answer your comment :) –  James Loghry Feb 11 at 0:45
    
Heirachy.. I'm guessing I cannot use a getall() –  Eric Luu Feb 11 at 0:47
    
Figured it out. Thank you! –  Eric Luu Feb 11 at 1:12
add comment

Ah, I've seen this problem when using standardsetController - as in recordSetVar="UserQueueSettings__c" on your apex:page component.

The default page size is 20 and AFAIK, you can't change this from the VF side, you need a controllerExtension. @James Loghry's solution avoids this 20 element page size issue by not using the standardsetController.

From the doc:

By default, a list controller returns 20 records on the page. To control the number of records displayed on each page, use a controller extension to set the pageSize. For information on controller extensions, see Building a Controller Extension.

StandardSetControllers are useful when you want to do pagination, simulating the way list views work on the standard UI.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.