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


Hi all,

           I have a pageblocktable where there are two columns. In the second column of the pageblocktable there is a datatable. There is a commandLink on each row in the secondcolumn of the pageblocktable. By clicking on the link in a particular row, datatable will appear on that particular row only of the pageblocktable with its corresponding values.

           But the problem I'm facing is that after clicking the link in a particular row of the pageblocktable its corresponding values (i.e the datatable) is displaying in all the rows of the pageblocktable. But I have to display the datatable in that particular row only.

           Here is the code of the visualforcepage


<apex:pageBlockTable value="{!statuspostlist}" var="status" border="0" cellpadding="6" cellspacing="13" columnsWidth="3">
<apex:column headerValue="Name">
<apex:column headerValue="Status">
<apex:image url="{!$Resource.fb45}" width="28px" height="28px" />&nbsp;&nbsp;
<apex:commandLink action="{!commentstatus}">
Comment<apex:param name="cmid" value="{!}"/>
<apex:outputPanel rendered="{!visible_comment =='show'}">
<apex:dataTable value="{!statuspost1.Comments__r}" var="cm">
<apex:column >


And the code of that method in apex is:


public PageReference commentstatus()
Id uid = System.currentPageReference().getParameters().get('uid');
Id cmid = System.currentPageReference().getParameters().get('cmid');
//comment = [select id,Comments__c,Status_Post__c,Userlogin__c from Comment__c where Status_Post__c=:cmid];
statuspost1 = [ select id,Status__c,Userlogin__c,User2__c,User2__r.Total_Name__c,Userlogin__r.Total_Name__c,
(select id,Comments__c,Status_Post__c,Userlogin__c from Comments__r) from Status_Post__c
where id=:cmid];
PageReference nextpage = ApexPages.currentPage();
visible_comment = 'show';
return nextpage;


So kindly if anyone have any suggestion about this,please help me.


Thanks in advance,


Arun KArun K



I have similar reuirement.


Any input would be appreciated.


Hi Kada,

I'm happy to make a follow up with you. For the above query I have used wrapper class to store the StatusPost and its corresponding comments so that for a particular status post , the number of comments can be displayed in that particular table. Just storing the StatusPost and its respective comments in a wrapper class and just use it in Vf through the wrapper class list.


If this solves your problem, kindly accept it as solution.





Just go through the code and this might come into help


public class MasterClass{

public List<statuswrapper> swrapper = new List<statuswrapper>();  {get; set; }

for(Status_Post__c obj:statuspostlist){

comment2 = [select id,Postcomment__c,Status_Post__c,Status_Post__r.Userlogin__c,Userlogin__c,
Userlogin__r.Total_Name__c from Comment__c where order by id];

statuswrapper newobj = new statuswrapper(obj.Userlogin__r.Total_Name__c,,obj.Userlogin__c,obj.Status__c,totallikes,comment2,like2,unlikeshow);



public class statuswrapper
public String name {get;set;}
public String id {get;set;}
public String userloginid {get;set;}
public String status{get;set;}
public Integer likes{get;set;}
public List<Comment__c> comments {get;set;}
public List<Like__c> likenames {get;set;}
public Like__c unlikenames {get;set;}

public statuswrapper(String name,String id,String userloginid,String status,Integer likes,List<Comment__c> comments,List<Like__c> likenames,Like__c unlikenames)
{ = name; = id;
this.userloginid = userloginid ;
this.status = status;
this.likes = likes;
this.comments = comments;
this.likenames = likenames;
this.unlikenames = unlikenames;


If this solves your problem, kindly accept it as solution.