+ Start a Discussion
sai tarunsai tarun 

One of the Interviewer asked to me

Hi All,
One of the Interviewer asked to me that
'I want to develop a visual force page,it will show the list of accounts,and i should be able to edit the account name and save it .For all accounts(Bulk Updating) or One Account, and i dont want to write any code..........You can you any method.......How can i achive that...............'?
How can can i achive this .............
Thanks in advance.............
 
Best Answer chosen by sai tarun
David HalesDavid Hales
Hi Sai Tarun,

By default it shows the 20 records at a time.
You have to add the pagination in the page like below.
<apex:page standardController="Account" recordSetVar="accounts" sidebar="false">
     <apex:form >
        <apex:pageBlock >
           <apex:pageMessages />
           
            <apex:pageBlockButtons >
               <apex:commandButton value="Save" action="{!save}"/>
               <apex:commandButton value="Return" action="{!cancel}"/>
            </apex:pageBlockButtons>
            

            <apex:pageBlockTable value="{!accounts}" var="acc" id="table">



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


              <apex:column headerValue="Website">
                 <apex:inputField value="{!acc.Website}"/>
               </apex:column>




              <apex:column headerValue="Account Site">
                  <apex:inputField value="{!acc.Site}"/>
               </apex:column>


               <apex:column headerValue="Fax">
                  <apex:inputField value="{!acc.Fax}"/>
               </apex:column>

           </apex:pageBlockTable>
           
           
           <apex:commandLink action="{!Previous}" value="Previous Page" rendered="{!HasPrevious}"/>
           <apex:commandLink action="{!Next}" value="Next Page" rendered="{!HasNext}"/>
           
         </apex:pageBlock>
      </apex:form>
 </apex:page>



I suggest you to go this book Visualforce In Practice - Chapter 4 (https://developerforce.com/guides/Visualforce_in_Practice.pdf) which has a lot of details on Standard Set Controller and recordSetVar along with how you can implement pagination, filterting, mass updates, etc..


Thanks & Regards
David Hales(1021)

All Answers

David HalesDavid Hales
Hi Sai Tarun,

Yes you can do this with the help of recordSetVar comonent  in custom visual force page.
 
<apex:page standardController="Account" recordSetVar="accounts" sidebar="false">
     <apex:form >
        <apex:pageBlock >
           <apex:pageMessages />
           
            <apex:pageBlockButtons >
               <apex:commandButton value="Save" action="{!save}"/>
               <apex:commandButton value="Return" action="{!cancel}"/>
            </apex:pageBlockButtons>
            

            <apex:pageBlockTable value="{!accounts}" var="acc" id="table">

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


              <apex:column headerValue="Website">
                 <apex:inputField value="{!acc.Website}"/>
               </apex:column>

              <apex:column headerValue="Account Site">
                  <apex:inputField value="{!acc.Site}"/>
               </apex:column>


               <apex:column headerValue="Fax">
                  <apex:inputField value="{!acc.Fax}"/>
               </apex:column>

           </apex:pageBlockTable>
         </apex:pageBlock>
      </apex:form>
 </apex:page>


Thanks & Regards
David Hales(1021)
 
David HalesDavid Hales
Please mark this is the best answer if your problem will solved.

Thanks & Regards
David Hales(1021)
 
sai tarunsai tarun
Hi Mr.David Hales,
Thank you for your Reply .....
I just Copy Paste your code to my vf page......
and the result (Screen shot Inserted).... I get only labels,ididn't get records.......
i had 50 records on my account object....
with out records how can i edit .......
please resolve it....
Thanks in advance.......
User-added image
David HalesDavid Hales
Hi Sai Tarun,

This is working fine in my Org.Have a look

User-added image

Please check you accounts record and tab visibility in your org.
Also give your profile to Account edit,delete and view all permission if not.
Let me know for more help in this regard.

Thanks & Regards
David Hales(1021)
 
sai tarunsai tarun
Thank you very much..............
sai tarunsai tarun
I got 20 out of 50 records..........

what, if i want to fetch large no.of recors??
 
David HalesDavid Hales
Hi Sai Tarun,

By default it shows the 20 records at a time.
You have to add the pagination in the page like below.
<apex:page standardController="Account" recordSetVar="accounts" sidebar="false">
     <apex:form >
        <apex:pageBlock >
           <apex:pageMessages />
           
            <apex:pageBlockButtons >
               <apex:commandButton value="Save" action="{!save}"/>
               <apex:commandButton value="Return" action="{!cancel}"/>
            </apex:pageBlockButtons>
            

            <apex:pageBlockTable value="{!accounts}" var="acc" id="table">



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


              <apex:column headerValue="Website">
                 <apex:inputField value="{!acc.Website}"/>
               </apex:column>




              <apex:column headerValue="Account Site">
                  <apex:inputField value="{!acc.Site}"/>
               </apex:column>


               <apex:column headerValue="Fax">
                  <apex:inputField value="{!acc.Fax}"/>
               </apex:column>

           </apex:pageBlockTable>
           
           
           <apex:commandLink action="{!Previous}" value="Previous Page" rendered="{!HasPrevious}"/>
           <apex:commandLink action="{!Next}" value="Next Page" rendered="{!HasNext}"/>
           
         </apex:pageBlock>
      </apex:form>
 </apex:page>



I suggest you to go this book Visualforce In Practice - Chapter 4 (https://developerforce.com/guides/Visualforce_in_Practice.pdf) which has a lot of details on Standard Set Controller and recordSetVar along with how you can implement pagination, filterting, mass updates, etc..


Thanks & Regards
David Hales(1021)
This was selected as the best answer
sai tarunsai tarun
Thank You soo much..............