javascript - Visualforce page is not refreshing after deleting a row from table -
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 + ' , approved: ' + userdeleted); /*contact contact = [select id, pg_contactapprovalstate__c contact id = :this.usid]; pg_contactapprovalstatus__c cas = [select id, pg_approvalstatus__c pg_contactapprovalstatus__c 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 contact id =:this.usid]; pg_contactapprovalstatus__c cas = [select id, pg_approvalstatus__c pg_contactapprovalstatus__c 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); }
i want refresh page after deleting user table, note:- if delete line "alert('record deleted successfully!');" script page refresh not working, delete function not working.
you need refresh table when action function processed, can rerender attribute.
add rerender attribute action function, id of component refreshed:
<apex:actionfunction action="{!dodelete}" name="setparams" rerender="contacttablepanel"> <apex:param name="param1" assignto="{!usid}" value="" /> <apex:param name="param2" assignto="{!userdeleted}" value="" /> </apex:actionfunction>
encapsulate table inside panel , assign id or add id desired component refreshed apex:actionfunction-
<apex:outputpanel id="contacttablepanel"> <table> .... </table> </outputpanel>
Comments
Post a Comment