KingTable icon indicating copy to clipboard operation
KingTable copied to clipboard

how to handle query cursor?

Open xnopasaranx opened this issue 7 years ago • 1 comments

Hello there! We are trying to implement kingTable into our software. However I cannot get it working as expected. I am trying to request data from the server and prepare this as JSON for kingtable to read. I have to limit my query to 99 objects and therefore need to pass a cursor to continue, and I can provide the total number of expected entries.

Is there any possibility to pass on a query cursor to kingTable?

xnopasaranx avatar Jan 24 '18 14:01 xnopasaranx

Hello! The library creates pagination automatically and sends GET requests with the following key-values inside the query string (example):

  "page": 1,
  "size": 30,
  "sortBy": "name asc, color desc, red asc",
  "search": null,
  "timestamp": "2017-04-29T19:08:36.800Z"

It expects a response object with the following information:

{
  items: [array], // array of items that respect the given filters (set of paginated results)
  total: [number] // the total count of items inside the collection (for example, the result of SQL Count(*))
}

Unfortunately it doesn't support, yet, scenarios in which the total count of items cannot be determined on the server side (for example, when using Azure Storage Table Service with continuation tokens). But I understand it's not this case, since you wrote that you can provide the total number of expected entries.

If you desire to add extra parameters to the query string or POST request body, you can use the option fetchData:

var table = new KingTable({
    fetchData: function () {
       // function called in the table context
       return {
          extraParam: 2
       };
    }
})

I hope this helps.

RobertoPrevato avatar Jan 24 '18 21:01 RobertoPrevato