Mass Update Records using Events
Update the Records when we click on Tab or Next field by using Events.
Visualforce :
<apex:page controller="MassUpdate">
<apex:form >
<apex:pageBlock title="Search Criteria" mode="edit" id="block" >
<apex:pageBlockButtons location="top">
<apex:pageMessages ></apex:pageMessages>
<apex:inputText value="{!body}"/>
<apex:commandButton value="Search" action="{!doSearch}" status="status12" reRender="block"/>
</apex:pageBlockButtons>
<apex:actionFunction name="ur" action="{!UpdateRecord}" reRender="pageblock" status="status12"/>
<apex:actionStatus startText="Requesting......." id="status12"></apex:actionStatus>
<apex:pageblockSection title="Account Details" columns="1" >
<apex:pageBlockTable value="{!item}" var="a">
<apex:column value="{!a.name}"/>
<apex:column headerValue="Name" >
<apex:inputField value="{!a.name}" onchange="ur();"/>
</apex:column>
<apex:column headerValue="Phone" >
<apex:inputField value="{!a.phone}" onchange="ur();"/>
</apex:column>
<apex:column headerValue="City" >
<apex:inputField value="{!a.Billingcity}" onchange="ur();"/>
</apex:column>
</apex:pageBlockTable>
</apex:pageblockSection>
</apex:pageBlock>
</apex:form>
</apex:page>
Controller :
public class MassUpdate {
public PageReferaence UpdateRecord() {
update Item;
return null;
}
list<account> Item;
public List<account> getItem() {
return Item;
}
public PageReference doSearch() {
string q='select id,Phone,billingcity,name from account where(name like\'%'+body+'%\')';
//string q='select id,name,type,billingcity,phone,billingcountry from account where(name like\'%'+body+'%\')';
Item=Database.query(q);
return null;
}
public String body { get; set; }
}
*Please Feel Free to Contact*
0 comments:
Post a Comment