Page 1 of 1

How can I have paging on my data?

Posted: Thu Jun 19, 2014 12:49 am
by Tooba Atif

I have a list having more than 100 items I want to show them 10 at one page and on click next button next 10 item appears.
How can i do this?
Is there any code reference for this?


How can I have paging on my data?

Posted: Thu Jun 19, 2014 12:53 am
by obullei

Hello Tooba!

How to make pages in your application you can learn here: http://devcenter.appery.io/tutorials/...


How can I have paging on my data?

Posted: Thu Jun 19, 2014 1:02 am
by Tooba Atif

Yeah I have gone through that tutorial but I want to know Can i do this for List component as well?
I have a list component which is populating from the local storage variable as my app is working for offline data.


How can I have paging on my data?

Posted: Thu Jun 19, 2014 1:59 am
by Tooba Atif

localStorage.getItem('test');

this test variable has 100 rows having id, address and name values
I need only 10 rows on 1st page so how can i get the rows?
I want to show only 10 items in list for 1st page


How can I have paging on my data?

Posted: Thu Jun 19, 2014 3:31 am
by Yurii Orishchuk

Hi Tooba.

I don't know what is realy in your "test" LSV.

But, if you put in this LSV serialized(to JSON) array(as you specified before) so you can use following solution:

pre

var testString = localStorage.getItem('test');

//Convert string to the JS object.
var testArray = JSON.parse(testString);

//These two variables should replaced with your needs.
var itemsPerPage = 10;
var currentPage = 2;

var pagedData = [];

var startItem = itemsPerPage * currentPage;
var endItem = startItem + itemsPerPage;
if(endItem testArray.length)
endItem = testArray.length;

for(var i = startItem; i < endItem; i++)
pagedData&#46;push(testArray[0]);

&#47;&#47;Here is you need to use your pagedData&#46;
console&#46;log(pagedData);

/pre

Regards.


How can I have paging on my data?

Posted: Thu Jun 19, 2014 4:36 am
by Tooba Atif

Thanks it worked :)