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
ganeshjujjuruganeshjujjuru 

Delete child records from Related List without refreshing the whole page

I have displayed Account records in pageblock table , and account names are displayed in command link when ever i click on command link the detail page of that particular account will displayed below the pageblock table , that detail page contains related list, from that related list i want to delete child records without refreshing the whole page that means here i want partial page refresh. Can any body help me..? 

souvik9086souvik9086

<apex:pageblocktable id="pageblkTable">

your code

<apex:commandLink action="{!delete}" value="Delete" rerender = "pageblkTable"/>

</apex:pageblocktable>

 

In controller 

public void delete(){

//Your code;

}

 

If this post is helpful please throw Kudos.If this post solves your problem kindly mark it as solution.

Thanks

 

ganeshjujjuruganeshjujjuru

This is my vf page

 

<apex:page controller="relatedlist1cls" showHeader="false">
<apex:form >
<apex:pageBlock >
<apex:pageBlockTable value="{!lstacc}" var="a">
<apex:column headerValue="Click Me">
<apex:commandLink value="{!a.name}" reRender="detail">
<apex:param value="{!a.id}" assignTo="{!aid}" name="name1"/>
</apex:commandLink>
</apex:column>
</apex:pageBlockTable>
</apex:pageBlock>
<apex:outputPanel id="detail">
<apex:detail subject="{!aid}"/>
</apex:outputPanel>
</apex:form>
</apex:page>

 

 

And this is my controller

 

public with sharing class relatedlist1cls {
public id aid{get;set;}
public list<Account> lstacc{get;set;}
public relatedlist1cls(){
lstacc=[select id,name from Account];
}
}

 

Please do here......

souvik9086souvik9086

<apex:page controller="relatedlist1cls" showHeader="false">
<apex:form >
<apex:pageBlock >
<apex:pageBlockTable value="{!lstacc}" var="a" id="pageBlkTable">
<apex:column headerValue="Click Me">
<apex:commandLink value="{!a.name}" reRender="detail,pageBlkTable">
<apex:param value="{!a.id}" assignTo="{!aid}" name="name1"/>
</apex:commandLink>
</apex:column>
</apex:pageBlockTable>
</apex:pageBlock>
<apex:outputPanel id="detail">
<apex:detail subject="{!aid}"/>
</apex:outputPanel>
</apex:form>
</apex:page>

 

From where are you calling the method for deleting?

 

If this post is helpful please throw Kudos.If this post solves your problem kindly mark it as solution.

Thanks

 

ganeshjujjuruganeshjujjuru

here if you click on Account name you have a detail page of that particular account detail page that account contains child(contact) records, here i have to delete those child(contact) records.

souvik9086souvik9086

Yes, that detail page and related list code is your visualforce. right? Then in that visualforce page you can use that rerender as I mentioned above for the partial refresh to rerender only that related list pageblocktable for the child records of accounts.

 

If this post is helpful please throw Kudos.If this post solves your problem kindly mark it as solution.

Thanks

Avidev9Avidev9
I guess he is talking about the standard Contact related list and standard delete button. I guess you wont be able to control this. This is the standard behaviour of SF. It refreshes the whole page
souvik9086souvik9086

Yes Avidev,

If it is a standard layout, nothing to do with it. :)

 

Thanks

ganeshjujjuruganeshjujjuru

so finally can we achieve this partial page refresh or not.. ? here

souvik9086souvik9086

If it is standard layout it can't be done. If it is custom VF page then you can proceed with the above posts of rerendering.

 

If this post is helpful please throw Kudos.If this post solves your problem kindly mark it as solution.

Thanks

Avidev9Avidev9

Ok here is a workaround for you.

 

Create a VF page with just 

<apex:page standardController="Account">
<apex:detail subject="{!Account.Id}"/>
</apex:page>

 Now modify the original code to display the above page in iframe

 

<apex:page controller="relatedlist1cls" showHeader="false">
   <apex:form >
      <apex:pageBlock >
         <apex:pageBlockTable value="{!lstacc}" var="a" id="pbt">
            <apex:column headerValue="Click Me">
               <apex:commandLink value="{!a.name}" reRender="detail,pbt">
                  <apex:param value="{!a.id}" assignTo="{!aid}" name="name1"/>
               </apex:commandLink>
            </apex:column>
         </apex:pageBlockTable>
      </apex:pageBlock>
      <apex:outputPanel id="detail">
         <!-- YOURVFPAGENAME is the name of the page that is created earlier to accomodate the  apex:detail -->
<apex:iframe src="/apex/YOURNEWVFPAGENAME?Id={!aid}"/> </apex:outputPanel> </apex:form> </apex:page>

 This will refresh the iframe only not the whole page.

Hope this helps

 

 

ganeshjujjuruganeshjujjuru

thnx for giving u r suggestions mr.souvik . Here  i am using custom VF page here where do you use rerendering pla do copy and page my code in your orgination you will understand clearly.. and the do answer.

Avidev9Avidev9
@ganeshjujjuru try the iframe approach that i just posted. That may help you
ganeshjujjuruganeshjujjuru

Thnx for giving reply here i am using Custom VF page where do you use rerendering please do copy paste my code in your orgination you will understandart clearly.

Avidev9Avidev9
I perfectly understand your problem and hence suggested you with the solution. Try the iframe approach. This will limit the refreshing to the iframe only
ganeshjujjuruganeshjujjuru

sorry 

Avidev9Avidev9
I am assuming detail1 is your new VFpage. Make sure you have showheader false and sidebar=false.

And have you selected any records using your click me link ?

Tried the same and is working for me
ganeshjujjuruganeshjujjuru

If it was working to you please send me code plzzzzzzzz

Avidev9Avidev9

There was lil mistake in the iframe code

 

<apex:iframe src="/apex/YOURNEWVFPAGENAME?Id={!aid}"/>

Should be

 

<apex:iframe src="/apex/YOURNEWVFPAGENAME?id={!aid}"/>

 

 

in "id", "i" is in small

ganeshjujjuruganeshjujjuru

Thanx Mr.

ganeshjujjuruganeshjujjuru

helloooo 

 

 

Thanx Mr.

Yoganand GadekarYoganand Gadekar

Mass delete component example here see if it helps you out,

http://cloudforce4u.blogspot.in/2013/06/visualforce-page-component-for-mass.html

Avidev9Avidev9
Not sure about the problem!
Can you please share a screenshot ?
ganeshjujjuruganeshjujjuru

kkk

ganeshjujjuruganeshjujjuru

here asking only plain text how can i share screenshots..?

Avidev9Avidev9
send it to my email its my username @gmail.com .
ganeshjujjuruganeshjujjuru

hello 

 

I have displayed Account records in pageblock table , and account names are displayed in command link when ever i click on command link the detail page of that particular account will displayed below the pageblock table , that detail page contains related list, from that related list i want to delete child records without refreshing the whole page that means here i want partial page refresh. Can any body help me..? 

ganeshjujjuruganeshjujjuru

kk

send u r mail id..

 

Avidev9Avidev9
I am still positive about the iframe solution! As it worked for me without any problem.
Again am saying make sure your other VF page that is displayed in iframe has sidebar="false" and showHeader="false" this will hide the standard headers and sidebar.!
ganeshjujjuruganeshjujjuru

yaa  i have done that bt i have got 2 more same pages in current page, how can u get proper result tell me once..?

Avidev9Avidev9
Please post your recent code!
ganeshjujjuruganeshjujjuru

kk this is my recent code 

 

Page:

 

<apex:page controller="relatedlist1cls" showHeader="false">
<apex:form >
<apex:pageBlock >
<apex:pageBlockTable value="{!lstacc}" var="a" id="pbt">
<apex:column headerValue="Click Me">
<apex:commandLink value="{!a.name}" reRender="detail,pbt">
<apex:param value="{!a.id}" assignTo="{!aid}" name="name1"/>
</apex:commandLink>
</apex:column>
</apex:pageBlockTable>
</apex:pageBlock>
<apex:outputPanel id="detail">
<!-- YOURVFPAGENAME is the name of the page that is created earlier to accomodate the apex:detail -->
<apex:detail subject="{!aid}"/>
<apex:iframe src="/apex/relatedlist1?id={!aid}"/>
</apex:outputPanel>
</apex:form>
</apex:page>

 

 

this is the controller:

 

public with sharing class relatedlist1cls {
public id aid{get;set;}
public list<Account> lstacc{get;set;}
public relatedlist1cls(){
lstacc=[select id,name from Account];
}
}

 

please check it out once

Avidev9Avidev9

Ohh god!!!

WHy the hell you have kept "<apex:detail subject="{!aid}"/>" in the page ?

I guess we moved it to the other page!

 

<apex:page controller="relatedlist1cls" showHeader="false">
   <apex:form >
      <apex:pageBlock >
         <apex:pageBlockTable value="{!lstacc}" var="a" id="pbt">
            <apex:column headerValue="Click Me">
               <apex:commandLink value="{!a.name}" reRender="detail,pbt">
                  <apex:param value="{!a.id}" assignTo="{!aid}" name="name1"/>
               </apex:commandLink>
            </apex:column>
         </apex:pageBlockTable>
      </apex:pageBlock>
      <apex:outputPanel id="detail">
         <!-- YOURVFPAGENAME is the name of the page that is created earlier to accomodate the apex:detail -->
         <apex:iframe src="/apex/relatedlist1?id={!aid}"/>
      </apex:outputPanel>
   </apex:form>
</apex:page>

 

ganeshjujjuruganeshjujjuru

without using this <apex:detail subject="{!aid}"/> how can u get related list..? form that code(u r sending code) how can u get related list tell me..? show me once...?

Avidev9Avidev9

Please get your fundamentals clear about iframe!

I already gave you solution and please do Read it carefully.

 

Create a VF page with just [this page will be displayed in the iframe to show the detail]

 

VF page Name : YOURNEWVFPAGENAME

<apex:page standardController="Account" showheader="false">
<apex:detail subject="{!Account.Id}"/>
</apex:page>

 Now modify the original code to display the above page in iframe

 VF Page Name : This is our original VF page

<apex:page controller="relatedlist1cls" showHeader="false">
   <apex:form >
      <apex:pageBlock >
         <apex:pageBlockTable value="{!lstacc}" var="a" id="pbt">
            <apex:column headerValue="Click Me">
               <apex:commandLink value="{!a.name}" reRender="detail,pbt">
                  <apex:param value="{!a.id}" assignTo="{!aid}" name="name1"/>
               </apex:commandLink>
            </apex:column>
         </apex:pageBlockTable>
      </apex:pageBlock>
      <apex:outputPanel id="detail">
         <!-- YOURVFPAGENAME is the name of the page that is created earlier to accomodate the  apex:detail -->
<apex:iframe src="/apex/YOURNEWVFPAGENAME?id={!aid}"/> </apex:outputPanel> </apex:form> </apex:page>

 This will refresh the iframe only not the whole page.

Hope this helps

ganeshjujjuruganeshjujjuru

if i will do that i got an error like "Id value is not valid for the Account standard controller

Avidev9Avidev9

ahhhh man!
Select a record from your link and see what happens!

IF it works you know what needs to be done ;)

 

else I fear that you have to hire a develoepr!

ganeshjujjuruganeshjujjuru

the links and table are not appear only that error will appear....

Avidev9Avidev9

ahhhh... this one is final I guess you are aware why this error is coming!

 

because at page load aid is NULL.

use rendered attributee to handle the situation

 

 <apex:outputPanel id="detail">
         <!-- YOURVFPAGENAME is the name of the page that is created earlier to accomodate the  apex:detail -->
<apex:iframe src="/apex/YOURNEWVFPAGENAME?id={!aid}" rendered="{!aid != NULL}"/> </apex:outputPanel>
ganeshjujjuruganeshjujjuru

Thanx alot Mr.