guillaumeoriol / serquant

Serquant library
4 stars 1 forks source link

new paginator for grids having variable item range #23

Closed guillaumeoriol closed 12 years ago

guillaumeoriol commented 12 years ago

The new Dojo dgrid uses variable item ranges. For instance, it will fetch items 0-24 first and then items 24-51 (ie 25 items the first time, then 28). As the item count is not a multiple of the item count per page, it results in a decimal page number.

The idea here is to build a paginator that is not based on page number/page size but that would directly use the supplied item range.

guillaumeoriol commented 12 years ago

The view scripts should be updated to:

$start = $paginator->getItemOffset();
if ($status === \Serquant\Service\Result::STATUS_SUCCESS) {
    // The result data is an instance of Zend_Paginator
    $paginator = $result->getData();

    // Return item range in the response header...
    $start = $paginator->getItemOffset();
    $currentItemCount = $paginator->getCurrentItemCount();
    if ($currentItemCount > 0) {
        $end = $start + $currentItemCount - 1;
    } else {
        $end = 0;
    }
    // ...
}