new operation/js/api/PaginationCursor(params)
stable API
Pagination response information produced by the service endpoint.
Describes what data were returned, that is count of records, whether they have some offset and whether a total of records is known.
This object is useful for both roles, Application Builder Business User and Application Builder Developer.
-
Developer can produce
PaginationCursor
instance after fetching data from corresponding service endpoint. If the server returns an information about the pagination state, (s)he can create an instance ofPaginationCursor
based on the result and pass it into OperationResult.success(..) so that client can consume it, if interested. -
Business User doesn't directly create instances of
PaginationCursor
. Usually calls OperationResult.Success.getPaginationCursor() to get one and pass it into PaginationRequest.createStandard(..) so that the subsequent calls are aware of the previous pagination state.
Parameters:
Name | Type | Description | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
params |
Object | Object literal with all possible parameters. Properties
|
- Version:
- 17.1.1
- Source:
- See:
-
- PaginationRequest which can use
PaginationCursor
for subsequent service calls. - PaginationRequest.createStandard(..) to pass an instance of
PaginationCursor
to create subsequent PaginationRequest.
- PaginationRequest which can use
Example
require([
'operation/js/api/PaginationRequest'
], function(PaginationRequest) {
var employee = Abcs.Entities().findById('my.custom.bop.Employee');
var firstPageRequest = PaginationRequest.createStandard({
pageSize: 15,
totalResults: true
});
var operation = Abcs.Operations().read({
entity: employee,
pagination: firstPageRequest
});
operation.perform().then(function(operationResult) {
if (operationResult.isSuccess()) {
// Process data from the first page any way you need
// Checks whether there are at least 15 further records available and
// if so, makes a subsequent call to fetch the next set of 15 records
var paginationCursor = operationResult.getPaginationCursor();
if (paginationCursor && paginationCursor.getTotal() > 30) {
var secondPageRequest = PaginationRequest.createStandard({
pageSize: 15,
cursor: paginationCursor
});
Abcs.Operations().read({
entity: employee,
pagination: secondPageRequest
}).perform().then(function(secondResult) {
// Process data from the second page any way you need
});
}
}
});
});
Methods
getCount() → {Integer}
stable API
Gets the real count of records returned by the performed Operation.
In most cases this is equal to what client defined in PaginationRequest's "pageSize" attribute. It can happen tho, that the server has only 5 records available, altough the client asked for next 10 records. In which case the value here will be the real value of records returned (5 in this case).
- Version:
- 17.1.1
- Source:
Returns:
- Type
- Integer
getOffset() → {Integer}
stable API
Gets the offset (= index of the first record from the resulted data set).
- Version:
- 17.1.1
- Source:
Returns:
- Type
- Integer
getTotal() → {Integer}
stable API
Gets the count of all records available on the server.
If client created PaginationRequest with "totalResults" attribute set to true
to find out the total number
of all records, the result will be available here. If the service, don't provide the capability to get the total count of the available records, undefined
will be returned here.
- Version:
- 17.1.1
- Source:
Returns:
- Type
- Integer