function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
daisy1153daisy1153 

visualforceでcolumnを横向きに表示するには

columnを横向きに表示させることは可能でしょうか。

 

例)

column1  row1 row2

column2 ...

column3 ...

 

どなたかご存知の方、ご教示のほどよろしくお願いいたします。

Taiki YoshikawaTaiki Yoshikawa

pageBlockTableとかでは横向き表示に変更する機能はないと思うので、tableタグとrepeatタグで対応する方法はどうでしょうか。

 

Page

<apex:page controller="HorizontalViewController" id="page">
    <apex:form id="form">
        <apex:pageBlock >
            <apex:outputPanel >
                <table border="1">
                    <tr>
                        <td>
                            <apex:outputText value="{!$ObjectType.Account.Fields.Name.Label}" styleClass="labelCol"/>
                        </td>
                        <apex:repeat value="{!accounts}" var="item">
                            <td>
                                <apex:outputField value="{!item.Name}" />
                            </td>
                        </apex:repeat>
                    </tr>
                    <tr>
                        <td>
                            <apex:outputText value="{!$ObjectType.Account.Fields.Phone.Label}" styleClass="labelCol"/>
                        </td>
                        <apex:repeat value="{!accounts}" var="item">
                            <td>
                                <apex:outputField value="{!item.Phone}" />
                            </td>
                        </apex:repeat>
                    </tr>
                </table>
            </apex:outputPanel>
        </apex:pageBlock>
    </apex:form>
</apex:page>

 

Controller

public with sharing class HorizontalViewController {
    
    public List<Account> accounts {get; set;}
    
    public HorizontalViewController() {
        this.accounts = [select Id, Name, AccountNumber, Phone, Rating from Account limit 200];
    }
}

 

 

Daisy_1153Daisy_1153

ご回答ありがとうございます。

 

意図した画面となりました。

ありがとうございました。


Taiki wrote:

pageBlockTableとかでは横向き表示に変更する機能はないと思うので、tableタグとrepeatタグで対応する方法はどうでしょうか。

 

Page

<apex:page controller="HorizontalViewController" id="page">
    <apex:form id="form">
        <apex:pageBlock >
            <apex:outputPanel >
                <table border="1">
                    <tr>
                        <td>
                            <apex:outputText value="{!$ObjectType.Account.Fields.Name.Label}" styleClass="labelCol"/>
                        </td>
                        <apex:repeat value="{!accounts}" var="item">
                            <td>
                                <apex:outputField value="{!item.Name}" />
                            </td>
                        </apex:repeat>
                    </tr>
                    <tr>
                        <td>
                            <apex:outputText value="{!$ObjectType.Account.Fields.Phone.Label}" styleClass="labelCol"/>
                        </td>
                        <apex:repeat value="{!accounts}" var="item">
                            <td>
                                <apex:outputField value="{!item.Phone}" />
                            </td>
                        </apex:repeat>
                    </tr>
                </table>
            </apex:outputPanel>
        </apex:pageBlock>
    </apex:form>
</apex:page>

 

Controller

public with sharing class HorizontalViewController {
    
    public List<Account> accounts {get; set;}
    
    public HorizontalViewController() {
        this.accounts = [select Id, Name, AccountNumber, Phone, Rating from Account limit 200];
    }
}