0

I am developing a code for "Use an inline Visualforce page in Record Details Page?". In this example,

InLineController

public class InLineController {
    public Contact cont {set; get; }
    public Id accRecId;
    public Account accRec {set; get; }

    public InLineController(ApexPages.StandardController controller){
        if(ApexPages.currentPage().getParameters().get('id') != null){
            Id id = ApexPages.currentPage().getParameters().get('id');
            accRecId = [select id,accountid from contact where id = :id].accountid;
            if(accRecId != null){
                accRec = [select id,name,accountnumber,annualrevenue from account where id =:accRecId];
            }
        }
    }
}

InLineControllerVFPage

<apex:page standardController="Contact" extensions="InLineController">
    <apex:form>
        <apex:pageBlock title="My Inline Visualforce page">
            <b>Account Name : </b><apex:outputField value="{!accRec.name}" /> <br/>
            <b>Account Number : </b><apex:outputField value="{!accRec.accountNumber}" /> <br/>
            <b>Annual Revenue : </b><apex:outputField value="{!accRec.annualrevenue}"/><br/>
        </apex:pageBlock>
    </apex:form>
</apex:page>

The only problem which I face is that I want "My Inline Visualforce page" in a single line. How we can get that ?

enter image description here

0

@Admano - As per suggestion, we can used it in the <apex:form style="white-space: nowrap;"> like below. It works fine.

<apex:page standardController="contact" extensions="InLineController">
    <apex:form style="white-space: nowrap;">
       <apex:pageBlock title="My Inline Visualforce page">
        <b>Account Name : </b> <apex:outputField value="{!accRec.name}"/><br/>
        <b>Account Number: </b> <apex:outputField value="{!accRec.accountnumber}"/><br/>
         <b>Annual Revenue : </b><apex:outputField value="{!accRec.annualrevenue}"/>
       </apex:pageBlock>
    </apex:form>
</apex:page>

enter image description here

  • I'm Adamo :D Remember that :D – Adamo Jun 12 '17 at 18:56
  • Thanx, Corrected your name. – user45930 Jun 12 '17 at 18:57
  • Great, simple solution works ! – user4567570 Jun 12 '17 at 18:58
  • No problem :D I joked – Adamo Jun 12 '17 at 18:58
1

You can use:

<apex:sectionHeader title="" subTitle=""/>

instead of

<apex:pageBlock title="My Inline Visualforce page">

Your example:

<apex:page standardController="Contact" extensions="InLineController">
    <apex:form>
      <apex:sectionHeader title="My Inline Visualforce page" subTitle=""/>`
        <apex:pageBlock>
            <b>Account Name : </b><apex:outputField value="{!accRec.name}" /> <br/>
            <b>Account Number : </b><apex:outputField value="{!accRec.accountNumber}" /> <br/>
            <b>Annual Revenue : </b><apex:outputField value="{!accRec.annualrevenue}"/><br/>
        </apex:pageBlock>
    </apex:form>
</apex:page>

--edit

Did you try add css style:

<style type="text/css">
.bPageBlock .pbBody { white-space: nowrap; }
</style>
  • No, I dont want to use it as SectionHeader, I want to use it as pageBlock only. – user4567570 Jun 12 '17 at 18:45
  • Understood. I add a new proposition – Adamo Jun 12 '17 at 18:47
  • Unsupported attribute style in <apex:pageBlock> in InLineControllerVFPage at line 3 column 88, we cant use style. – user4567570 Jun 12 '17 at 18:49
  • Please check my last edit. – Adamo Jun 12 '17 at 18:54
1

The page section needs to be one column edit the page layout to set it as 1 column.

  • Great, simple solution works ! – user4567570 Jun 12 '17 at 18:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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