Di Zou
Di Zou

Reputation: 4609

How do I customize the columns in a apex:listView?

I have a apex:listView for my Cases:

<apex:ListViews type="Case">
</apex:ListViews>

When I display this page, I get the columns Action, Case Number, Contact Name, Subject, Status, Priority, Date/Time Opened, and Case Owner Alias.

How would I customize which columns show up and what order the columns are in?

Thanks.

Upvotes: 0

Views: 5544

Answers (2)

Di Zou
Di Zou

Reputation: 4609

This is what I ended up doing:

<apex:page standardController="Case" recordSetVar="Case" sidebar="true" showHeader="true">
    <apex:form >
        <apex:pageBlock title="Cases">
              <apex:outputLabel value="View:"/>
              <apex:selectList value="{!filterId}" size="1">
                <apex:actionSupport event="onchange" rerender="cases_table"/>
                <apex:selectOptions value="{!listviewoptions}"/>
              </apex:selectList>
            <apex:pageBlock >
                <apex:pageBlockButtons >
                </apex:pageBlockButtons>
                <apex:pageBlockTable value="{!case}" var="c" rows="50" id="cases_table" >
                    <apex:column >
                        <a target="_parent" href="{!URLFOR($Action.Case.View, c.id)}">{!c.CaseNumber}</a>
                        <apex:facet name="header">Case Number</apex:facet>
                    </apex:column>
                    <apex:column value="{!c.ContactId}" />
                    <apex:column value="{!c.Subject}" />
                    <apex:column value="{!c.Status}" />
                    <apex:column value="{!c.Priority}" />
                </apex:pageBlockTable>
            </apex:pageBlock>
        </apex:pageBlock>
    </apex:form>
    <base target="_parent"/>
</apex:page>

Upvotes: 3

Matt K
Matt K

Reputation: 7337

Apex List Views, similar to standard list views, contain a picklist at the top followed by an Edit button and a Create New View button. You can modify the view by clicking on the Edit button. There is no way, that I am aware of, to modify the columns programmatically. If you need more control, you could use another tag, such as <apex:pageblocktable>, as JCD mentioned in the question comments.

List View Picklist Edit Button

Upvotes: 1

Related Questions