You need to sign in to do that
Don't have an account?

Rerender problem
page:
<script>
function deleteEmployee(EId){
var res = confirm('Are you sure?');
if(res == true){
doexecute(EId);
}
}
</script>
<apex:form >
<apex:actionfunction name="doexecute" action="{!doDelete}" rerender="pb">
<apex:param name="empId" value="" assignTo="{!employeeId}"/>
</apex:actionfunction>
<apex:outputpanel id="pb">
<apex:pageBlock >
<apex:pageBlockTable value="{!lstE}" var="E">
<apex:column headerValue="Action">
<apex:commandlink value="Del" onclick="deleteEmployee('{!E.Id}')" rerender="pb">
</apex:commandlink>
</apex:column>
<apex:column headerValue="Employee Name" value="{!E.Name}"/>
</apex:pageBlockTable>
</apex:pageBlock>
</apex:outputpanel>
class:
public String employeeId{get;set;}
public void doDelete() {
delete [select id from Employee__c where id =: employeeId];
}
public List<Employee__c> lstE{get;set;}
public AccDataclass(){
lstE = new List<Employee__c>();
lstE = [select id,name from Employee__c];
}
Once i deleted a record then the pageblock table is not updated. It still showing the deleted records also. When i am refreshing the browser it clears the deleted records.
Any Idea!
Hi,
this is not the rendering problem, how they automatically query the records again?
You need to call it again when call delete method or use get method.
There r two approch:
First : Create the get Method like
public String employeeId{get;set;}
public List<Employee__c> lstE{get;set;}
public void doDelete() {
delete [select id from Employee__c where id =: employeeId];
}
public List<AccDataclass(){}
public List< Employee__c> getEmployees() {
List<Employee__c> lstE = new List<Employee__c>();
lstE = [select id,name from Employee__c];
return lstE;
}
And use in VF as:
<apex:pageBlockTable value="{!Employees}" var="E">
<apex:column headerValue="Action">
<apex:commandlink value="Del" onclick="deleteEmployee('{!E.Id}')" rerender="pb">
</apex:commandlink>
</apex:column>
<apex:column headerValue="Employee Name" value="{!E.Name}"/>
</apex:pageBlockTable>
SECOND:
Call a method from Class constructor:
public String employeeId{get;set;}
public List<Employee__c> lstE{get;set;}
public AccDataclass(){
employeeList(); // Call the method from constructor.
}
public void employeeList() {
lstE = new List<Employee__c>();
lstE = [select id,name from Employee__c];
}
public void doDelete() {
delete [select id from Employee__c where id =: employeeId];
employeeList(); // Call the same method from Delete method.
}
And Use in VF as you have done:
<apex:pageBlockTable value="{!lstE}" var="E">
<apex:column headerValue="Action">
<apex:commandlink value="Del" onclick="deleteEmployee('{!E.Id}')" rerender="pb">
</apex:commandlink>
</apex:column>
<apex:column headerValue="Employee Name" value="{!E.Name}"/>
</apex:pageBlockTable>
Please let me know if u have any problem on same and if this post helps u please throw KUDOS by click on star at left.