+ Start a Discussion
vijju123_1vijju123_1 

confussion on <apex:pageBlockSectionItem>

hiee dis is vijay

 

                          i want to knw why we use <pageblocksectionitem> and any small expample for it..thanks in advance :)

Best Answer chosen by Admin (Salesforce Developers) 
Kamatchi Devi SargunanathanKamatchi Devi Sargunanathan

Hi,

 

No worries, just simple.. Normally, when we use pageblock or pageblocksection,for the field value you are using like <apex:inputField> you can directly get your field label along with the field type, and also alignments will be like standard page layout. But, If you specify any field value with <apex:inputtext> you won't get the field alignment properly and also wont get the field label.

 

But, by using PageblockSectionItem, you can use the input/output text tags with proper alignment. For Example, first inputtext is mentioned in pageblocksectionItem is followed by 2 columns alignments if specified.

 

If you want to feel the difference, then try the below examples.

 

Try page without pageblocksectionItem,

<apex:page standardController="Account">
    <apex:form>
        <apex:pageBlock title="My Content" mode="edit">
            <apex:pageBlockButtons>
                <apex:commandButton action="{!save}" value="Save"/>
            </apex:pageBlockButtons>

            <apex:pageBlockSection title="My Content Section" columns="2">
              
                    <apex:outputLabel value="Account Name" for="account__name"/>
                    <apex:inputText value="{!account.name}" id="account__name"/>
             
                    <apex:outputLabel value="Account Site" for="account__site"/>
                    <apex:inputText value="{!account.site}" id="account__site"/>
            
        </apex:pageBlock>
    </apex:form>
</apex:page>

 


Try Page with pageblocksectionItem,

<apex:page standardController="Account">
    <apex:form>
        <apex:pageBlock title="My Content" mode="edit">
            <apex:pageBlockButtons>
                <apex:commandButton action="{!save}" value="Save"/>
            </apex:pageBlockButtons>
            <apex:pageBlockSection title="My Content Section" columns="2">
               <apex:pageBlockSectionItem>
                    <apex:outputLabel value="Account Name" for="account__name"/>
                    <apex:inputText value="{!account.name}" id="account__name"/>
                </apex:pageBlockSectionItem>


                <apex:pageBlockSectionItem>
                    <apex:outputLabel value="Account Site" for="account__site"/>
                    <apex:inputText value="{!account.site}" id="account__site"/>
                </apex:pageBlockSectionItem>
            </apex:pageBlockSection>
        </apex:pageBlock>
    </apex:form>
</apex:page>

 

Also, for your reference see the following link,

http://www.salesforce.com/us/developer/docs/pages/Content/pages_compref_pageBlockSectionItem.htm

 

Hope so this helps you...!

 

Please mark this answer a Solution and please give kudos by clicking on the star icon, if you found this answer as helpful.

All Answers

ericmonteericmonte

I use Page Block Section Item if i want to change the field Label but still use the value from the feld.

 

For example

 

<apex:pageblockSectionItem>

CUSTOM FIELD LABEL:

<apex:outputField value="{!Contact.LastName}"/>

 

</apex:pageBlockSectionItem>

Kamatchi Devi SargunanathanKamatchi Devi Sargunanathan

Hi,

 

No worries, just simple.. Normally, when we use pageblock or pageblocksection,for the field value you are using like <apex:inputField> you can directly get your field label along with the field type, and also alignments will be like standard page layout. But, If you specify any field value with <apex:inputtext> you won't get the field alignment properly and also wont get the field label.

 

But, by using PageblockSectionItem, you can use the input/output text tags with proper alignment. For Example, first inputtext is mentioned in pageblocksectionItem is followed by 2 columns alignments if specified.

 

If you want to feel the difference, then try the below examples.

 

Try page without pageblocksectionItem,

<apex:page standardController="Account">
    <apex:form>
        <apex:pageBlock title="My Content" mode="edit">
            <apex:pageBlockButtons>
                <apex:commandButton action="{!save}" value="Save"/>
            </apex:pageBlockButtons>

            <apex:pageBlockSection title="My Content Section" columns="2">
              
                    <apex:outputLabel value="Account Name" for="account__name"/>
                    <apex:inputText value="{!account.name}" id="account__name"/>
             
                    <apex:outputLabel value="Account Site" for="account__site"/>
                    <apex:inputText value="{!account.site}" id="account__site"/>
            
        </apex:pageBlock>
    </apex:form>
</apex:page>

 


Try Page with pageblocksectionItem,

<apex:page standardController="Account">
    <apex:form>
        <apex:pageBlock title="My Content" mode="edit">
            <apex:pageBlockButtons>
                <apex:commandButton action="{!save}" value="Save"/>
            </apex:pageBlockButtons>
            <apex:pageBlockSection title="My Content Section" columns="2">
               <apex:pageBlockSectionItem>
                    <apex:outputLabel value="Account Name" for="account__name"/>
                    <apex:inputText value="{!account.name}" id="account__name"/>
                </apex:pageBlockSectionItem>


                <apex:pageBlockSectionItem>
                    <apex:outputLabel value="Account Site" for="account__site"/>
                    <apex:inputText value="{!account.site}" id="account__site"/>
                </apex:pageBlockSectionItem>
            </apex:pageBlockSection>
        </apex:pageBlock>
    </apex:form>
</apex:page>

 

Also, for your reference see the following link,

http://www.salesforce.com/us/developer/docs/pages/Content/pages_compref_pageBlockSectionItem.htm

 

Hope so this helps you...!

 

Please mark this answer a Solution and please give kudos by clicking on the star icon, if you found this answer as helpful.

This was selected as the best answer
Subhani PSubhani P

Hi Vijay,

 

There are a couple of good links which gives information about the use of  <pageblocksectionitem> . check the following links once.

 

http://th3silverlining.com/2010/03/29/the-pageblock-elements-inputfield/

 

 

 

http://th3silverlining.com/2010/03/29/the-pageblock-elements-inputfield/

 

If this post is helpful please throw Kudos.If this post solves your problem kindly mark it as solution.

 

Thanks,
Subhani,
Salesforce Certified Developer,
www.mydbsync.com