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
Rafael.Martins.SantosRafael.Martins.Santos 

Refresh the cell without refresh the visualforce page

Hi All,

How do I update a table ("<table>") without refresh the page?

for example:

I have a <td> and inside of this tag I have a Select options field, that when I change the value, fire a actions that update the value in account and deppending of the value the cell of this <td> must update with a background color.
The value update on the account normally but the color of the cell is changing after I reload the page.
But the problem is, if I reload the page, I lost all the data that are displaing in the page, forcing me to make a search again.

So, I want update the account, update the background cell and remain with the all current data.

is it possible?

Thanks

Rafael 
Best Answer chosen by Rafael.Martins.Santos
Rafael.Martins.SantosRafael.Martins.Santos
Hi Pradeed,

After many many many many time expend on this issue I solve :)

Here is the code that I used and work:

I Add <apex:outputPanel id="page" > before the table tag and I add in the action function the actionSupport, that reRender the outputPanel.
<apex:actionFunction name="executar" action="{!Save}" reRender="null">
          <apex:param name="id_contas" value="" assignTo="{!id_conta}"/>
          <apex:param name="suporte_status" value="" assignTo="{!status_conta}"/>
          <apex:actionSupport action="{!Save}" event="oncomplete" rerender="page"/>
        </apex:actionFunction>

Pradeep, thanks for your help, for your time and for your patience.

Rafael

All Answers

pradeep kumar yadavpradeep kumar yadav
Try this......
 
<apex:page >
    <apex:form>
    	<apex:pageBlock>
        	<apex:pageBlockSection>
                <apex:selectList onchange="FN1()">
                    <apex:selectOptions value="Options"/>
                </apex:selectList>
                <apex:actionFunction name="FN1" action="{!method_To_Execute}" reRender="op"/>
            	<apex:outputPanel id="op">
                	<apex:pageBlockTable>

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

 
pradeep kumar yadavpradeep kumar yadav
you reRender any block of code by putting the code in outputPanel and reRender output panel using actionFunction.

Hope...It Helps
Rafael.Martins.SantosRafael.Martins.Santos
hi pradeep,
I used the reRender and this is reloading before the Apex code finish. So the data is not updated.

I gonna share my code here and you will see how it's working.


Here is my visualforce code:

<table>
        <apex:form >
        <apex:actionFunction name="executar" action="{!Save}" reRender="null">
          <apex:param name="id_contas" value="" assignTo="{!id_conta}"/>
          <apex:param name="suporte_status" value="" assignTo="{!status_conta}"/>
        </apex:actionFunction>


            <apex:repeat value="{!TodasContas}" var="conta">
            <tr>
            <td class="celula_cinza_claro"><apex:outputLink value="/{!conta.Id}" >{!conta.Name}</apex:outputLink></td>
            <td style="{!if(conta.Suporte_Status__c == 'Fabricante','background-color:#1C1C1C; font-weight: bold; color:white !important', 
                         if(conta.Suporte_Status__c == 'Concorrente','background-color:#CD0000; font-weight: bold', 
                         if(conta.Suporte_Status__c == 'N/A','background-color:#FFD700; font-weight: bold',
                         if(conta.Suporte_Status__c == 'Oportunidade','background-color:#9ACD32; font-weight: bold', 'background-color:#EEE9E9; font-weight:bold'))))}" >

                 <apex:inputField value="{!conta.Suporte_Status__c}" id="suporte" onchange="gravar('{!conta.Id}', '{!$Component.suporte}');" styleClass="inputField_custom"></apex:inputField>
             </td>
            
            </tr>
            </apex:repeat>
            </apex:form>
</table>


So if you see, in the tag td, I have a conditional that will change de background of the cell, but it is working only after I reload the page.
And if I use the reRender as true or calling a method, the Apex controller code is not executed.
The list that I say before is a field of the account and I'm calling by:
<apex:inputField value="{!conta.Suporte_Status__c}" id="suporte" onchange="gravar('{!conta.Id}', '{!$Component.suporte}');" styleClass="inputField_custom"></apex:inputField>
pradeep kumar yadavpradeep kumar yadav
<apex:actionFunction name="executar" action="{!Save}" reRender="null">

here what is 'null' , here you should put the id of that particular block which shoud be reRendered...
from Database...
pradeep kumar yadavpradeep kumar yadav
You have to call the action function ...

<apex:inputField value="{!conta.Suporte_Status__c}" id="suporte" onchange="gravar('{!conta.Id}', '{!$Component.suporte}'), executar()
Rafael.Martins.SantosRafael.Martins.Santos
Hi Pradeed,

After many many many many time expend on this issue I solve :)

Here is the code that I used and work:

I Add <apex:outputPanel id="page" > before the table tag and I add in the action function the actionSupport, that reRender the outputPanel.
<apex:actionFunction name="executar" action="{!Save}" reRender="null">
          <apex:param name="id_contas" value="" assignTo="{!id_conta}"/>
          <apex:param name="suporte_status" value="" assignTo="{!status_conta}"/>
          <apex:actionSupport action="{!Save}" event="oncomplete" rerender="page"/>
        </apex:actionFunction>

Pradeep, thanks for your help, for your time and for your patience.

Rafael
This was selected as the best answer