function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
khushbukhushbu 

Auto refresh datatable

Hello all salesforce team,

 

   I am new for salesforce.

 

  I am having one issue .I want to autorefresh my datatable on any event when  DML operation (insert,update,delete )occur.

I have tried actionpollar . but it wont work.

 

Please direct me.

 

Thanks

 

Khushbu Shah

Best Answer chosen by Admin (Salesforce Developers) 
souvik9086souvik9086

I'm not finding any other way for that auto page refresh on DML fire.

 

Thanks

All Answers

souvik9086souvik9086

Rerender the command button from which the method you called from Page for Saving the record i.e for DML operation. For e.g

 

<apex:outoutpanel id="datatableid">

<apex:datatable>

//Your logic

</apex:datatable>

</apex:outputpanel>

<apex:commandbutton action="{!YourMethod}" value="Save" rerender="datatableid"/>

 

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

Thanks

 

 

khushbukhushbu

Thanks a lot for reply.

 

Actualy , I have created  object.

 

I have manually inserted 5 records in it.

 

I have created one page in that I am having one datatable .

 

Now what I want is :

 

 Whenever my data is being updated , deleted or new data inserted , My grid should be refreshed.

 

I have tried actionPoller.

 

But I dont want to refresh my page on some fix period of time or on some commandButton action.

 

I want to autorefresh my page on DML operations on that object only.

 

  Here is my code :

 

<apex:page showHeader="false" sidebar="false" standardController="employee__c" recordSetVar="employee">
<apex:pageBlock title="Customer Overview">
<apex:form id="abc" >
<apex:dataTable value="{!employee}" var="emp" id="emptable" rowClasses="odd,even"

styleClass="tableClass">

 

<apex:column >

<apex:facet name="header">Employee ID</apex:facet>

<apex:outputText value="{!emp.empID__c}"/>

</apex:column>

<apex:column >

<apex:facet name="header">Employee Name</apex:facet>

<apex:outputText value="{!emp.empName__c}"/>

</apex:column>
<apex:actionPoller rerender="emptable" interval="5"/>
</apex:dataTable>

</apex:form>
</apex:pageBlock>


</apex:page>

 

 

Please help

souvik9086souvik9086

 

Khushbu,

 

This is looking not possible in my eyes.

You can judge whether a DML occurs or not through Trigger and Workflow but you can't automatically refresh a page on the event of DML operation.

 

It can only be done as to refresh the page on some fix period of time through action poller.

 

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

Thanks

 

khushbukhushbu

But ActionPoller will call that method in every 5  0r 10 seconds to check for any DML operations..Is there any other way to do this?

 

 

 

souvik9086souvik9086

I'm not finding any other way for that auto page refresh on DML fire.

 

Thanks

This was selected as the best answer
khushbukhushbu

OK . Thanks a lot for your response.

khushbukhushbu

Hello,

 

 

I have got some other solution.

 

I want to refresh some pageblock only after some period of time.

 

I have used this code :

 

   

<apex:page showHeader="false" sidebar="false" standardController="employee__c" recordSetVar="employee">

<apex:pageBlock title="Customer Overview">
<apex:form id="abc" >
<apex:dataTable value="{!employee}" var="emp" id="emptable" rowClasses="odd,even"

styleClass="tableClass">

 

<apex:column >

<apex:facet name="header">Employee ID</apex:facet>

<apex:outputText value="{!emp.empID__c}"/>

</apex:column>

<apex:column >

<apex:facet name="header">Employee Name</apex:facet>

<apex:outputText value="{!emp.empName__c}"/>

</apex:column>
<apex:actionPoller rerender="emptable" interval="5"/>
</apex:dataTable>

</apex:form>
</apex:pageBlock>


</apex:page>

 

 

 

Here I want to rerender my datatable through action pollar in every 5 seconds. But it is not working.....Can u please help me?