You need to sign in to do that
Don't have an account?

how to display the long list in different lines in a page
I have a requirement where there is a list of strings which is quite big, around few thousands. but need to be displayed in different lines and could be able to export/ take print etc...
please check the below image for reference.
please help.

please check the below image for reference.
please help.
List<List<string>> toDisplay = new List<List<string>>();
First list behing rows, second one behing columns.
You then populate that double list based on your initial list :
List<string> initialList = new List<string>()
//Add x thousand entries to the list here
integer nbOfColumns = 8;
List<List<string>> toDisplay = new List<List<string>>();
List<string> currentList = new List<string>();
for(string str : initialList)
{
if(currentList.size()>=nbOfColumns)
{
toDisplay.add(currentList);
currentList = new List<string>();
}
currentList.add(str);
}
if(currentList.size()>0)
{
toDisplay.add(currentList);
}
Once the list of list is exposed in visualforce :
<table>
<apex:repeat value="{!ListOfList}" var="List">
<tr>
<apex:repeat value="{!List}" var="entry">
<td>{!entry}</td>
</apex:repeat>
</tr>
</apex:repeat>
</table>
You could also achive the same with standard vf component using the same logic, but it was faster to write using table html tags :)
I hope it solve your issue!
All Answers
Basically you should be able to string.split your input and output in the format you want in a visualforce page.
How does the code aquire the string? Is it a document in salesforce? An attachment? Result from an http request?
Regards,
we are doing the query to fetch the eligible records.and adding the field with number to list<String>, so everything ready to go but the display.
List<List<string>> toDisplay = new List<List<string>>();
First list behing rows, second one behing columns.
You then populate that double list based on your initial list :
List<string> initialList = new List<string>()
//Add x thousand entries to the list here
integer nbOfColumns = 8;
List<List<string>> toDisplay = new List<List<string>>();
List<string> currentList = new List<string>();
for(string str : initialList)
{
if(currentList.size()>=nbOfColumns)
{
toDisplay.add(currentList);
currentList = new List<string>();
}
currentList.add(str);
}
if(currentList.size()>0)
{
toDisplay.add(currentList);
}
Once the list of list is exposed in visualforce :
<table>
<apex:repeat value="{!ListOfList}" var="List">
<tr>
<apex:repeat value="{!List}" var="entry">
<td>{!entry}</td>
</apex:repeat>
</tr>
</apex:repeat>
</table>
You could also achive the same with standard vf component using the same logic, but it was faster to write using table html tags :)
I hope it solve your issue!