+ Start a Discussion
Mani PenumarthiMani Penumarthi 

displaying th list values in vf page

for example i show u,

 

SUBJECTNAMENO:----------------------> this is the header for the table

xxxbha123

xxxmnb2145

xxxnbg145

 

here every thing is fine, but the problem is if the SUBJECT has same value and havinf more than 1 record as shown above,

the subject should be displayed to only first record , for other records it should be hidden.

 

please help me how to do thi?

bob_buzzardbob_buzzard

So if I understand correctly, you only want to show a single instance of each unique subjectname, rather than duplicates?

 

That being the case, I think you are going to have to carry out the processing server side and build a map keyed by subjectname.  Then you can guarantee that regardless of how many entries you put into the map against the subjectname, only the last one will be retained.  Then you can back your table with the values from the map.

Navatar_DbSupNavatar_DbSup

Hi,

You can achieve this by wrapper class

Try the below code snippet as reference:

------- vf page---------

<apex:page controller="cloumnrepeat" >

<Apex:pageBlock >

 

<apex:pageBlockTable value="{!wrapper1}" var="aa">

<apex:column headerValue="Subject"  >{!aa.subject}</apex:column>

 

<apex:column headerValue="Account Name" >{!aa.accountname}</apex:column>

 

<apex:column headerValue="Contact Name" >{!aa.contactname}</apex:column>

</Apex:pageBlockTable>

 

</Apex:pageBlock>

 

 

 

</apex:page>

 

-------------- Apex controller ----------------

public class cloumnrepeat

{

public list<task> t1{get;set;}

public list<wrappertest> wrapper1{get;set;}

public cloumnrepeat ()

{

    t1=[select id ,subject,what.name,who.name from task limit 1000];

    t1.sort();

    wrapper1=new list<wrappertest>();

    if(t1.size()>0)

    {

        wrappertest wp1=new wrappertest();

        wp1.subject=t1[0].subject;

        wp1.accountname=t1[0].what.name;

        wp1.contactname=t1[0].who.name;

        wrapper1.add(wp1);

       

    }

    for(integer i=1;i<t1.size();i++)

    {

       wrappertest wp1=new wrappertest();

        wp1.accountname=t1[i].what.name;

        wp1.contactname=t1[i].who.name;

        if(t1[i].subject!=t1[i-1].subject)

        {

            wp1.subject=t1[i].subject;

        }

        else

        {

        wp1.subject='';

        }

        wrapper1.add(wp1);

       

    }

    system.debug('@@@@@@@@@@'+wrapper1.size());

}

 

public class wrappertest

{

    public string subject{get;set;}

    public string accountname{get;set;}

     public string contactname{get;set;}

   

}

 

}

 

Did this answer your question? If not, let me know what didn't work, or if so, please mark it solved.