Data pagination to load data from JSDO catalog

Posted by Valeriy Bashkatov on 10-Feb-2014 08:02

Hello,

I want to create pagination for listitems by loading data from JSDO (not from database). It needed for my ProKB Mobile  project (http://goo.gl/tg0zlP) to create pagination for ProKb articles list and  considering search query.

I think that in this case it is better to work with the results in JSDO, and not to request constantly to the database.

Unfortunately I have not found a suitable example to understand how to do it.

I would be grateful if someone share such example.

Regards,
Valeriy

All Replies

Posted by egarcia on 11-Feb-2014 06:02

Hello,

I do not have an example, but I wanted to give you some suggestions.

In most cases, you would want to do data pagination from the server (database). In this way, you can return a subset of records instead of a large number of records to correspond to the the result that you want to browse.

Currently, there is no built-in support for data pagination. However, you can use the approach used in the Sports 2013 sample app ( oemobiledemo.progress.com/preview1.html ).

This sample app adds a "record id" field to the temp-table and uses a callback method for an AFTER-ROW-FIELD in the Business Entity to populate the field with the ROWID of the record in the database.

The client code then keeps track of the record id for each page. Then it passes the record id of the last record in the page in the filter parameter so that the Business Entity can return a new page starting from this record (this means that this record is now the first record in the page). The Business Entity uses the RESTART-ROWID method of the DATA-SOURCE to read the records from the page. BATCH-SIZE is used to specify the number of records to return.

We currently, have this approach described in one of the our training materials but not in the documentation.

Something that we have considered as a future enhancement, is to have built-in support for data pagination in the JSDO so that it can download pages of data and cache the data in the JSDO memory.

In regards to doing data pagination from the JSDO and using JSDO Services, there is no specific support to do this.

There is a way that you can do it today but you would need to change the JSDORead [Service] code (you can see it in the JavaScript section) so that you the mapping to the list would use a subset of records from the JSDO rather than number.

I would not like to recommend this approach because the JSDORead code is something that we would be enhancing and changing in the future. (We could add hooks or an approach that would allow you to change some behavior of the service.)

Here is a possible approach if you still want to try it.

You can access the JSDO local memory using the getData() method. This method returns the data as an array. You would have to keep a variable (localStorage) with the page number. Then in the JSDORead code, you can set than when readLocal is set (this is a parameter to the service), which corresponds to isLocal in the code, instead of passing "data" as a parameter to settings.success(), you would need to pass an slice (page) of the array as an object with the same structure that "data" uses.

I hope this helps.

Posted by Ricardo Perdigao on 11-Feb-2014 09:27

Hi,

If you decide to implement the approach used on the Sports 2013 sample described by Edsel above, please let us know here and I will post the backend code and the client JavaScript that goes with it to help you.

All the best

Posted by Valeriy Bashkatov on 12-Feb-2014 01:39

Hello,

You mean the "Using JSDO in Progress OpenEdge Mobile Applications (1000-021) (Rev. 2)" course, chapter about implementing  batch read?

I found it just now. I will try to do it...

Thanks for the hint!

Posted by mflanegan on 21-Nov-2014 00:35

Hi there,

Where would I find:

"Using JSDO in Progress OpenEdge Mobile Applications (1000-021) (Rev. 2)"

Thanks in advance.

Meyrick

Posted by Ricardo Perdigao on 21-Nov-2014 00:49

Meyrick,

This is part of the Progress Training Catalog for OE (wbt.progress.com) and you need a subscription to access it. I've looked at it and it describes/explains the implementation of batching I've forwarded to you long time ago (back and forward with a small set of records). Good thing you have the sample, because the training doesn't seem to have the code that does the batching itself.

Regards,

Ricardo Perdigao

Posted by mflanegan on 21-Nov-2014 00:54

Thanks Ricardo, I replied to that post before I saw your reply to my batching post. Thanks.
 

Meyrick Flanegan

Developer - Managed Services

Email: mflanegan@elcb.co.za

 

ELCB Information Services (Pty) Ltd

Customer Service Email  elcb@elcb.co.za · www.elcb.co.za

E A S T  L O N D O N

Tel: +27(43)  704 0700

Fax: +27(43) 704 0701

J O H A N N E S B U R G

Tel: +27(11) 879 6179

Fax: +27(11) 454 0384

P O R T  E L I Z A B E T H

Tel: +27(41) 373 0529

Fax: +27(86) 650 0135

Disclaimer


[collapse]
From: Ricardo Perdigao [mailto:bounce-rperdiga@community.progress.com]
Sent: 21 November 2014 08:50 AM
To: TU.Mobile@community.progress.com
Subject: RE: [Technical Users - Mobile] Data pagination to load data from JSDO catalog
 
Reply by Ricardo Perdigao

Meyrick,

This is part of the Progress Training Catalog for OE (wbt.progress.com) and you need a subscription to access it. I've looked at it and it describes/explains the implementation of batching I've forwarded to you long time ago (back and forward with a small set of records). Good thing you have the sample, because the training doesn't seem to have the code that does the batching itself.

Regards,

Ricardo Perdigao

Stop receiving emails on this subject.

Flag this post as spam/abuse.

[/collapse]

This thread is closed