You need to sign in to do that
Don't have an account?
Drawloop
Paginate Records using QueryResultIterator in Flex
I would like to be able to start with showing records 1-200 from a particular query, then when a button is clicked show records 201-400. Here is what I have so far:
This gets me the first set of records fine but when I run this code a second time it still gives me the first results. What am I missing? Do I have to use an event listener?
Thanks!
Tracy
Code:
apex.batchSize = 200; var d:QueryResultIterator = new QueryResultIterator(apex, querystr, function (so:SObject):Boolean { var qr:QueryResult = d.queryResult(); for (var i:int = 0; i < qr.records.length; i++) { var q:QueryResult = (qr.records[i] ? qr.records[i] : qr.records); //display record } return false; } );
This gets me the first set of records fine but when I run this code a second time it still gives me the first results. What am I missing? Do I have to use an event listener?
Thanks!
Tracy
I think you may want to think about ditching the iterator and doing it manually (as you are pretty much doing anyway) by calling queryMore when you want the next batch of records. If you want to be able to scroll back too, you'll want to store that information somewhere other than just the QueryResult object.
I get errors when I try to move the display records code to its own function so I have the same bits of code written out three times. A bit annoying, but it's working!
The code here still doesn't look quite right -- seems like you may be doing lots of queryMores where you don't need to. If you're doing the query within the context of the iterator, it should do all the queryMores for you in the background. What if you ditch the iterator altogether and just go with a straight up query() call with your query, and then queryMore on that?
Hello Drawloop,
can you please paste your whole code here to help me out?
I have to do a fetch lots of records ( in 100000 nos.) and need to do pagination, currently I am using
PHP webservice to fetch records, but handle to paging is difficult.
Please guide about this.
Thanks