Tooba Atif
Posts: 0
Joined: Fri Apr 04, 2014 3:07 am

How can I have paging on my data?

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?

obullei
Posts: 0
Joined: Thu Jun 05, 2014 12:17 am

How can I have paging on my data?

Hello Tooba!

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

Tooba Atif
Posts: 0
Joined: Fri Apr 04, 2014 3:07 am

How can I have paging on my data?

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.

Tooba Atif
Posts: 0
Joined: Fri Apr 04, 2014 3:07 am

How can I have paging on my data?

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

Yurii Orishchuk
Posts: 0
Joined: Fri Feb 14, 2014 8:20 am

How can I have paging on my data?

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.

Tooba Atif
Posts: 0
Joined: Fri Apr 04, 2014 3:07 am

How can I have paging on my data?

Thanks it worked :)

Return to “Issues”