You need to sign in to do that
Don't have an account?
t.deepthi05
show more in vf page by querying only once
Hi,
I have list of records displaying with repeat tag in visualforce page.I want intially to show 5 records and then on button click i want display next 5 records along with the current records in the same page until i have records in the list.
I have https callouts so i want to implemt the above functionality using java script
how to set the repeat size value to 5 intially and incerment it further using javascript
I have list of records displaying with repeat tag in visualforce page.I want intially to show 5 records and then on button click i want display next 5 records along with the current records in the same page until i have records in the list.
I have https callouts so i want to implemt the above functionality using java script
how to set the repeat size value to 5 intially and incerment it further using javascript
For this you can add a apex command link for "Show More" at the bottom of Page Block, and on click of that you can perform an action that refreshes the merge field of pageBlockTable with more data as desired , in the Last you can rerender that pageBlockTable.
You can pass the limit in the soql query .when click on the show more link call the action method and increase the limit and again execute the soql query and rerender you pageblock table.
See the thread below,
https://developer.salesforce.com/forums?id=906F0000000986iIAA
Regards,
Ashish
In above example every time we icrement the limit of the page and each time clicking on the link we would run an soql
My requriment i just want to append new records to the existing page without runing an Soql.
1 list will hold all of the values and the 2nd will hold 5 values to show on the page.
You will need a counter variable to process BIG list into smaller. In this case additional querries will be avoided.
So, dynamically changing list, a counter, Full list and rerender functionallity for the list is required.
I've done something simillar, but as an apex component(like a widget) and it worked absolutely fine.
controller:
page:
mark my response as a best answer if it fits you.
Good luck :)
See the SOQL with pagination and Offset sample in the links below,
The Joys of SOQL Pagination
https://developer.salesforce.com/blogs/tech-pubs/2012/06/the-joys-of-soql-pagination.html
Pagination on VisualForce Page using multiple soql queries.
https://developer.salesforce.com/forums/ForumsMain?id=906F0000000AE85IAG
SOQL Offset
https://developer.salesforce.com/blogs/developer-relations/2012/01/soql-offset-in-spring-12.html
Regards,
Ashish
What do you think?
No offence, just a discussion.
PS: anyway, I didn't knew about "OFFSET", so thanks! :)
You are right querying everytime wont be a Best Practice.
I would suggest you to use links below the table for next 25 records which will use Offset and get the next 25.
Also, See the below thread,
Show more link on bottom PageBlockTable
<apex:page controller="AddShowmoreInPageBlockTableController">
<apex:sectionHeader title="Home" subtitle="Account"/>
<apex:form>
<apex:pageBlock title="Recent Accounts" >
<apex:pageBlockTable value="{!accts}" var="account" id="table">
<apex:column headerValue="Account Name">{!account.Name}</apex:column>
<apex:column headerValue="Billing City">{!account.BillingCity}</apex:column>
<apex:column headerValue="Phone">{!account.Phone}</apex:column>
</apex:pageBlockTable><br/>
<apex:commandLink value="Show 25 items" action="{!showmoreAccount}" reRender="table" />
<apex:commandLink value="Show 10 items" onclick="window.location.reload();" rendered="{!Enable=='edit2'}"/>
</apex:pageBlock>
</apex:form>
</apex:page>
controller is..........
public class AddShowmoreInPageBlockTableController {
public String Enable{get;set;}
public Account account{get;set;}
public List<Account> accts{get;set;}
public AddShowmoreInPageBlockTableController() {
accts = [select Id,Name,BillingCity,Phone from Account limit 10];
}
public PageReference showmoreAccount() {
accts = [select Id,Name,BillingCity,Phone from Account limit 25];
Enable='edit2';
return null;
}
}
https://developer.salesforce.com/forums?id=906F0000000986iIAA
Regards,
Ashish
You can store quite a big list inside the controller and it will be OK for the view state(I made tests some time before)
We can take around 1k records into the big list, and read by 5 records each time we need to show more. If we get further than 1k records, only then we should create another querry.
I just wanted include on thing i have callouts and if i have more than 10 records in vf page it is displaying a callout expection.
That if i calling more than 10 at time
currently i am using standard set controller and using pagination to display the records which is avoiding me the exception.
But now i wanted to replicate pagination with show more option
Thats hitting a Governor limit, you have to program to avoid hitting Limit.
A single Apex transaction can make a maximum of 10 callouts to an HTTP request or an API call.
http://www.salesforce.com/us/developer/docs/apexcode/Content/apex_callouts_timeouts.htm
See below for sample code,
Apex Code Best Practices
https://developer.salesforce.com/page/Apex_Code_Best_Practices
Salesforce API 10 request limit
http://stackoverflow.com/questions/5859290/salesforce-api-10-request-limit
Regards,
Ashish