javascript - 从表中删除行后,Visualforce 页面不刷新

标签 javascript jquery salesforce apex

SCRIPT:
function dodelete(id,deleted) {
    /*alert("UserId");*/
    $("input[id$='hdUserId']").val(id);
    $("input[id$='hdnDeleted']").val(deleted);
    //alert(id);
    //alert(deleted);
    setParams(id,deleted);
    //setInterval(50000);
    alert('Record deleted successfully!');
}
PAGE:
</tr>
<apex:repeat value="{!staffInfo.StaffAccepted}" var="u" id="staffaccepted" rendered="{!staffInfo.StaffAccepted.size <> 0 && staffInfo.StaffAccepted.size <> null}">
   <tr>
      <td>{!u.FullName}</td>
      <td>{!u.Email}</td>
      <td>{!$Label[u.Role]}</td>
      <td>{!$Label[u.RegType]}</td>
      <td>
         <a href="#" class="Reset" onclick="doResetPassword('{!u.contact}');return false;">{!$Label.PG_ApprovalProcess_Reset}</a>/
         <apex:outputPanel rendered="{!IF(u.valide, true, false)}">
            <apex:form style="margin:0px;">
               <apex:commandLink onclick="dodelete('{!u.contact}',true);" >  Delete</apex:commandLink>
               <!--<apex:actionSupport event="onclick" action="{!dodelete}" rerender="tabref"/>-->                                                                            
            </apex:form>
         </apex:outputPanel>
      </td>
   </tr>
</apex:repeat>
<apex:form >
   <apex:actionFunction action="{!dodelete}" name="setParams" rerender="dummy">
      <apex:param name="param1" assignTo="{!UsId}" value="" />
      <apex:param name="param2" assignTo="{!userDeleted}" value="" />
   </apex:actionFunction>
</apex:form>

Controller:

public void dodelete()
{
System.debug('PG_ApprovalController.doAction() called: Id: ' + UsId + ' and approved: ' + userDeleted);
/*Contact contact = [select Id, PG_ContactApprovalState__c from Contact where Id = :this.UsId];
PG_ContactApprovalStatus__c cas = [select Id, PG_ApprovalStatus__c from PG_ContactApprovalStatus__c where Id = :contact.PG_ContactApprovalState__c];
system.debug('PG_ContactApprovalStatus__c found, Id : ' + cas.Id + ', status : ' + cas.PG_ApprovalStatus__c);
if(userDeleted) 
{
    cas.PG_ApprovalStatus__c = PG_Enums.APPROVAL_STATUS_TYPE.Deleted.name();
    update cas;
    system.debug('Deleted');
} */
Contact contact = [select Id, PG_ContactApprovalState__c from Contact where Id =:this.UsId];
PG_ContactApprovalStatus__c cas = [select Id, PG_ApprovalStatus__c from PG_ContactApprovalStatus__c where Id = :contact.PG_ContactApprovalState__c];
system.debug('PG_ContactApprovalStatus__c found, Id : ' + cas.Id + ', status : ' + cas.PG_ApprovalStatus__c);
if(userDeleted) 
{
    cas.PG_ApprovalStatus__c = PG_Enums.APPROVAL_STATUS_TYPE.Deleted.name();
    update cas;            
    system.debug('Deleted');
    PageReference nextPage = new PageReference('/apex/PG_PharmacyOverview');
    nextPage.setRedirect(true);
}
    //update cas;
    system.debug('Entered ###########>>>>>>>>>>:'+p);
}

我想在从表中删除用户后刷新页面, 笔记:- 如果我删除 LINE "alert('记录删除成功!');"从脚本页面刷新不起作用,甚至删除功能也不起作用。

最佳答案

处理操作函数时需要刷新表格,可以使用 rerender 属性来做到这一点。

在action函数中添加rerender属性,即要刷新的组件的id:

<apex:actionFunction action="{!dodelete}" name="setParams" rerender="contactTablePanel">
    <apex:param name="param1" assignTo="{!UsId}" value="" />
    <apex:param name="param2" assignTo="{!userDeleted}" value="" />
</apex:actionFunction>

将表格封装在面板内,并分配一个Id或将id添加到任何需要从apex:actionfunction刷新的组件中-

<apex:outputPanel id="contactTablePanel">
    <table>
        ....
    </table>
</outputPanel>

关于javascript - 从表中删除行后,Visualforce 页面不刷新,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30817882/

相关文章:

javascript - 跨浏览器问题 css

php - 脚本在 Ajax 返回值中不起作用

javascript - 我们如何制作带有背景图像属性的图像轮播

java - 如何使用 Java 将自定义字段添加到 salesforce 中的现有对象

ios - 在 IOS 中离线时保持登录销售团队

javascript - 日期时间 atrr 中的正则表达式

c# - 使用 JQuery 将自定义集合对象从 Controller 传递到 View

javascript - 将 jQuery 的 data() 与 Mustache.js 模板结合使用

testing - Salesforce/Apex,为什么 TestDataFactory 类包含在代码覆盖率中?

javascript - 基于 ng-class 中的插值添加多个三元运算和条件