Salesforce 对 visualforce 组件保留了 1000 个限制,因为大型数据表的重新渲染性能非常糟糕,并且可能使浏览器冻结,这是需要注意的事情。
随着列表开始变大,您需要注意的解决方法是堆大小。如果数据太大,我建议使用过滤(on SOQL
)来减少需要返回给浏览器的数据。(Select2
会成功的)
有几种方法可以解决问题。这是其中的几个...
- 使用行和第一个参数来设置显示数据的偏移量和限制:
<apex:repeat value="{!myCollection}" var="item" rows="1000" first="0">
{!item.text}
</apex:repeat>
<apex:repeat value="{!myCollection}" var="item" rows="1000" first="1000">
{!item.text}
</apex:repeat>
<apex:repeat value="{!myCollection}" var="item" rows="1000" first="2000">
{!item.text}
</apex:repeat>
- 使用包装:
视觉力量页面:
<apex:page controller="thousandLimit">
<apex:pageBlock >
<apex:repeat value="{!thousandBlocks}" var="block">
<apex:pageBlockTable value="{!block.Accounts}" var="a">
<apex:column value="{!a.Name}"/>
</apex:pageBlockTable>
</apex:repeat>
</apex:pageBlock>
</apex:page>
控制器:
public class thousandLimit
{
private limitWrapper[] thousandBlocks = new limitWrapper[]{};
private final integer listLimit;
public thousandLimit()
{
listLimit = 999;
}
public limitWrapper[] getthousandBlocks()
{
thousandBlocks = new limitWrapper[]{};
integer counter = 0;
integer loopCount = 0;
Account[] tmpAccount = new Account[]{};
for(Account a:[SELECT Id, Name FROM Account])
{
if(counter < listLimit)
{
tmpAccount.add(a);
counter++;
}
else
{
loopCount++;
thousandBlocks.add(new limitWrapper(tmpAccount,loopCount));
tmpAccount = new Account[]{};
tmpAccount.add(a);
counter = 0;
}
}
if(thousandBlocks.size() == 0)
{
loopCount++;
thousandBlocks.add(new limitWrapper(tmpAccount,loopCount));
}
return thousandBlocks;
}
public class limitWrapper
{
public Account[] accounts {get;set;}
public integer blockNumber {get;set;}
public limitWrapper(Account[] accs, integer i)
{
accounts = accs;
blockNumber = i;
}
}
}
- 您可以将用户readonly
标签从1k 增加到 10k:
<apex:page controller="thousandLimit" readonly="true">
<apex:pageBlock >
<apex:repeat value="{!thousandBlocks}" var="block">
<apex:pageBlockTable value="{!block.cases}" var="c">
<apex:column value="{!c.CaseNumber}"/>
<apex:column value="{!c.owner.name}"/>
<apex:column value="{!c.App_Process__c}"/>
<apex:column value="{!c.Load__c}"/>
<apex:column value="{!c.subject}"/>
<apex:column value="{!c.Estimated_Completion_Date__c}"/>
<apex:column value="{!c.Complete__c}"/>
<apex:column value="{!c.Priority}"/>
<apex:column value="{!c.Case_Age_Days__c}"/>
</apex:pageBlockTable>
</apex:repeat>
</apex:pageBlock>
</apex:page>