You need to sign in to do that
Don't have an account?
Sachin Patil 57
How to iterate through 2 lists in a single pageblock table.
Hi all,
I have a task to create a table where i should iterate through 2 lists(dynamic lists). I have used Wrapper class for lists. Below is the code that I have used.
Please someone help me with the code below
*************VisualForce Page************** <apex:pageBlockSection columns="2" > <apex:pageBlockTable value="{!wrapLists}" var="wrap"> <apex:column headerValue="API Names" value= "{!wrap.APINamesList}" /> <apex:column headervalue="CSV Fields" value="{!wrap.allCSVFields}" /> </apex:pageBlockTable> </apex:pageBlockSection> *********Controller************ public void getApiNames(){ wrap = new wrapperClass(); queryResults = [SELECT API_Names__c,Object__c,Label FROM dataload__mdt WHERE Label= :selectedFunction ]; allAPINames = queryResults[0].API_Names__c; wrap.APINamesList = new List<string>(); APIList= new List<String>(); wrapLists.clear(); for(string APINames: allAPINames.split(',')){ APINamesMap.put(APINames, APINames); system.debug('Test2'+APINames); wrap.APINamesList.add(APINames); System.debug('TEster'+wrap.APINamesList); wrapLists.add(wrap); // APIList.add(APINames); } } Public void saveFile(){ for(string sac: APIList){ if(CSVList.contains(sac)){ insert objDataLoader; objAttachment.ParentId = objDataLoader.id; insert objAttachment; } } } Public void readcsvFile(){ CSVList= new List<string>(); csvFileLines = new List<String>{}; wrap.allCSVFields= new List<String>(); wrapLists.clear(); csvAsString = csvFileBody.toString(); csvfileLines = csvAsString.split('\n'); for(string st: csvfileLines[0].split(',')){ wrap.allCSVFields.add(st); wrapLists.add(wrap); //CSVList.add(st); } } public class wrapperClass{ public List<string> allCSVFields {get;set;} public List<String> APINamesList {get; set;} }
https://salesforce.stackexchange.com/questions/103455/how-do-i-display-multiple-list-in-a-table
If i declare them as string, How can store all the values into a list.
I tried by declaring it as string, and I assigned the Wrap.allCSVFields= st; It is showing only the last value of the list.
But I am getiing as below when I tried to print in a page block table