PDA

View Full Version : Return specific number of items from Store



andrewmoff
11 Jul 2012, 1:02 AM
Apologies once again, this seems like it should be very simple, I thought there might be a property to set or similar but I cant seem to find what I'm looking for.

I just want to only return the first 5 items from my Store, I've already applied a custom Sorter to shuffle the order of the Store data, now I just want to return 5 items?

sword-it
11 Jul 2012, 2:01 AM
Hi!

you may do the following to retrieve first 5 items from your store:-




yourStore.getRange([0],[4]);


check this:-http://docs.sencha.com/touch/2-0/#!/api/Ext.data.Store-method-getRange

OR




var firstFiveRecords=[];
for(var i=0;i<5;i++){
firstFiveRecords.push(yourStore.getAt(i));
}

// now firstFiveRecords(which is an array) contains first 5 records from your store