Forum Stats

  • 3,837,057 Users
  • 2,262,222 Discussions
  • 7,900,192 Comments

Discussions

Using data from REST POST API with OJ Table

DaveArch
DaveArch Member Posts: 125 Red Ribbon

JET Version: 10.0

Hi JET Community

We have a requirement to fetch data from a REST API that requires information sent to it as a HTTP POST and serve it up in an OJ Table (appreciating that the API does not conform to REST principles in that it should really be a GET). This is due to the complexity of the payload required to filter the data from the service.

Typically with JET 10.x, we would use OJ Collection and OJ Model with OJ Table to give us light-weight data fetching along all the nice paging for free. Given that this is a POST, we cannot do that (unless anyone has a bright ideas on this).

Therefore, we would typically look to use ArrayDataProvider or MutableArrayDataProvider to help us here where we would pre-load the data provider in one hit. Unfortunately, we could be dealing with fairly large data sets and therefore don’t want to be fetching all the data over the network in one go. The API does support fetch size and offset in the POST payload so we need to work out how to leverage that with the table itself.

We were thinking therefore that we could listen for an event which indicated that the user had scrolled down past the watermark which triggers the data provider to do a fetch and then perform the POST request with the relevant offset and fetch size. We would then load that into the underlying array backing the data provider.

We have been looking through the API’s and the Cookbook but can’t see a pattern for this.

Does anyone have any ideas?

Many thanks

Best Answer

Answers