Pergunta

I have a listview using LoadMore. The data-click loads a detail view and I am fetching the data from the existing dataset using getByUid().

data = dsOfferList.getByUid(e.view.params.uid);

Is there a way I can know what page of the datasource that record belongs? If I use dsOfferList.page(), I get the page number of the dataset after its last change event, not necessarily the page the listview item came from.

For example, say I have a dataset with 200 total records and I am using serverPaging and pageSize of 50. Intially, dsOfferList.page() will return 1. I then scroll down the list and click the Load More button. Now dsOfferList.page() will return 2. But if I scroll back up the list a few items, those items (still loaded in the DOM) came from page 1. I need to be able to click one of the listview items and know if it was loaded from the page 1 datasource or the page 2 datasource.

How can I get the page number of the clicked listview item?

Foi útil?

Solução 2

So far I have not found a way to access the current datasource.page() from schema.parse() however, you can from datasource.change(). I ended up using the datasource.change() function to push the returned data row-by-row (including the page variable) into a second datasource object. So now every time the datasource fires, it automatically updates the second datasource with the data, including the page variable that I needed.

One thing to remember, the UIDs for the second datasource are different even though you are passing the UID from the first datasource. I set the schema.id in both datasources and utilize this when referencing a particular row of data.

Outras dicas

You can do something like this

data = dsOfferList.getByUid(e.view.params.uid);
var index = dsOfferList.data().indexOf(data);
var page = Math.round(index/dsOfferList.pageSize()) + 1;
Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top