You need to sign in to do that
Don't have an account?
using checkbox to select fields to update
I have a requirement where, on a VF page I am displaying different fields of an Account record.
There should be checkbox before each field. On checking it, the corresponding
field will be Editable.
There will be a submit button on clicking of which the record will be updated.
vf page:
<apex:page controller="SupplierUpdate">
<apex:form >
<apex:pageBlock id="theBlock">
<apex:pageBlockSection columns="2">
<apex:inputField value="{!acc.Trading_Title__c}" />
<apex:inputField value="{!acc.Collection_Address__c}" />
<apex:inputField value="{!acc.Account_Name__c}" />
<apex:inputField value="{!acc.Collection_Street__c}" />
<apex:inputField value="{!acc.Website}" />
<apex:inputField value="{!acc.Collection_Post_Code__c}" />
<apex:inputField value="{!acc.CPH_Holding_No__c}" />
<apex:inputField value="{!acc.Correspondence_Address__c}" />
<apex:inputField value="{!acc.Depot__c}" />
<apex:inputField value="{!acc.Correspondence_Street__c}" />
<apex:inputField value="{!acc.Phone}" />
<apex:inputField value="{!acc.Corresondence_City__c}" />
<apex:inputField value="{!acc.Fax}" />
<apex:inputField value="{!acc.Correspondence_Postcode__c}" />
<apex:commandButton action="{!submit}" value="Submit" />
</apex:pageBlockSection>
</apex:pageBlock>
</apex:form>
</apex:page>
And the controller(incomplete) is
public class SupplierUpdate {
public Account acc{get;set;}
public SupplierUpdate (){
acc = new Account();
SupplierUpdataion ();
}
public void SupplierUpdatation (){
try{
//getting info of logged-in user
User userLatest=[select id,profile.id,contactId,profile.name from User where id=:UserInfo.getUserId()];
//getting the account associated with the logged-in user
acc=[select id,,Name,Account_Name__c,Phone,Fax,Website,Collection_Address__c,Collection_City__c,Collection_Street__c,
Collection_Country__c,Collection_County__c,Collection_Post_Code__c,Trading_Title__c,
from account where owner.Id = :userLatest.Id];
}
catch(Exception e){
apexpages.addmessage(new apexpages.message(apexpages.severity.info,'Contact Your System Admin.'));
}
}
public pageReference submit(){
update acc;
return null;
}
}
Thanks in advance.
I can't see any checkboxes or handlers in this page - have you tried to implement this and hit problems, or are you posting your requirements and expecting someone to present you the solution?
Hi Bob,
Yes, I tried to put checkboxes before the fields and using rerender on the pageblocksection.
Like this :
<apex:inputCheckbox value="?">
<apex:actionSupport event="onchange" rerender="theBlock"/>
</apex:inputCheckbox>
But, couldn't find feasible way.
Thanks