+ Start a Discussion
surya kanadhipatlasurya kanadhipatla 

Issue: Splitting single field values into multiples columns of a page-block table(urgent)

Hi all, i have used the Vf page and controller to split the values of a single filed into multiple columns.

The issue is each name is getting diplayed 3 times on the page. But if i use Set insted a List i'm able to eliminate the duplicates.

Please see the below code and let me know where exactly the issue is(i guess the issue is inside the for loop but could not sort it out
Note: i'm using custom settings object and retrieving the values to display them on page with a name and checkbox
VF page: 
	<apex:pageBlockTable value="{!MyWrappers}" var="wrap" id="pgtbl">
   <apex:column width="100px">
 <apex:inputCheckBox value="{!wrap.checkbox1}"/>
 <apex:outputField value="{!wrap.mySec1.name}"/>
    </apex:column>
 <apex:column width="100px">
   <apex:inputCheckBox value="{!wrap.checkbox2}"/>
    <apex:outputField value="{!wrap.mySec2.name}"/>
 </apex:column>
 <apex:column width="100px">
   <apex:inputCheckBox value="{!wrap.checkbox3}"/>
   <apex:outputField value="{!wrap.mySec3.name}"/> 
 </apex:column>
</apex:pageBlockTable>

Controller code:
public with class Controller {
Public  List<MyWrapper> myWrappers{get; set;}

public class MyWrapper
 {
    public Boolean checkbox1{get;set;}
    public Boolean checkbox2{get;set;}
    public Boolean checkbox3 {get;set;}
    public Custom_settings_Object__c myLead1{get;set;} 
    public Custom_settings_Object__c myLead2{get;set;}
    public Custom_settings_Object__c myLead3{get;set;}
    
 }     
    public pagereference initiallds()----calling this action from page component
    {     
  myWrappers=new List<MyWrapper>();
  Integer idx=0;
  MyWrapper wrap;      
    for(Custom_settings_Object__c ld: Custom_settings_Object__c.getall().values())   
    {               
      if (Math.mod(idx, 3)==0)
       {   
          wrap =  new MyWrapper();
           wrap.myLead1=ld; 
           
       }
      if (Math.mod(idx, 3)==1)
       {
          wrap.myLead2=ld;
      
       }
   if (Math.mod(idx, 3)==2)
       {           
       wrap.myLead3=ld;
           
       }           
          ++idx;        
          myWrappers.add(wrap);
                }    
return null;
    }
	}



 
Best Answer chosen by surya kanadhipatla
Prasad Avala(SFDC)Prasad Avala(SFDC)
Hi Surya, Can you cut line number  55 (myWrappers.add(wrap);) and paste it at line 52 and let me know? if the issue is resolved.

 

All Answers

surya kanadhipatlasurya kanadhipatla
Please check the below attachment:
attachment
AshlekhAshlekh
Hi,

Check you Data in Custom_settings_Object__c.  I thing some think is wrong in you data,

If in data is correct then please post you VFP code and Class code completely;

-Thanks
Ashlekh Gera

 
surya kanadhipatlasurya kanadhipatla
Hi AKG,
Thanks for the response. I have used a custom object instead custom settings object data still the same issue.

I have already posted all the VF and controller code. Please check the screenshot of rendered page as well.

I really appreciate your help...
Prasad Avala(SFDC)Prasad Avala(SFDC)
Hi Surya, Can you cut line number  55 (myWrappers.add(wrap);) and paste it at line 52 and let me know? if the issue is resolved.

 
This was selected as the best answer
surya kanadhipatlasurya kanadhipatla
Thanks Prasad. That worked....