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“警告('记录删除成功!');”从脚本页面刷新不起作用,甚至删除功能也无法正常工作。
答案 0 :(得分:0)
您需要在处理动作功能时刷新表,您可以使用rerender属性执行此操作。
将rerender属性添加到action函数中,该函数是要刷新的组件的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或add id:actionfunction -
<apex:outputPanel id="contactTablePanel">
<table>
....
</table>
</outputPanel>