You need to sign in to do that
Don't have an account?
bibbi84
Removing row from a table with JQuery-> Why page refresh automatically?
Hi,
my issue is this : I have a simple pageblocktable with some records,when I remove one specific row from the table ... this work well for a moment, then my page is automatically reloaded with the complete pageblocktable and all the rows.
My wish is not delete a record, but to make impossible the view of a row.
This is the code of my controller:
public with sharing class e2cprovasearchcontroller2 { public List<E2C_Email__c> emailsmod; public List<E2C_Email__c> getEmailsmod (){ String id='500T0000004QpWr'; this.emailsmod=[Select id,subject__c,FromName__c,Read__c,CreatedDate,CcAddress__c from E2C_Email__c where Case__c=:id ORDER BY CreatedDate DESC]; return this.emailsmod; } }
This is the code of my page :
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.min.js" /> <script src="https://ajax.microsoft.com/ajax/jquery.ui/1.8.5/jquery-ui.js"/> <link rel="stylesheet" type="text/css" media="screen" href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.18/themes/base/jquery-ui.css" /> <script type="text/javascript"> //modifico il selettore in modo da non avere conflitti con jquery. $j = jQuery.noConflict(); function hiderows(){ var prova= $j('#subject'+ 'a0TT0000003BMmGMAW').parent(); var prova2=$j('#subject'+ 'a0TT0000003BMmGMAW').closest("tr"); prova2.remove(); } </script> <apex:form > <apex:outputpanel > <apex:commandbutton value="prova" onclick="hiderows()" /> </apex:outputpanel> </apex:form> <apex:outputpanel layout="block" style="overflow:auto;height:200px"> <apex:pageBlock id="pb" mode="maindetail"> <apex:pageBlockTable value="{!Emailsmod}" var="e" columns="5" cellspacing="5" onRowClick="show(this)"> <apex:column headerValue="From" width="22%"> <span id="from{!e.id}"> {!e.FromName__c} </span> </apex:column> <apex:column headerValue="Subject"> <span id="subject{!e.id}"> {!e.Subject__c} </span> </apex:column> <apex:column headerValue="Date" width="7%"> <span id="date{!e.id}"> <apex:outputText value="{0,date,dd/MM/yy hh:mm}"> <apex:param value="{!e.CreatedDate}" /> </apex:outputText> </span> </apex:column> </apex:pageBlockTable> </apex:pageBlock> </apex:outputpanel>
Thanks to all,
F.P.
an apex:commandButton will normally submit and refresh the page. You can either supress this by making your onclick method return false, or just use an HTML <button> if you don't need apex:commandButton functionality.