Skip to content
This repository has been archived by the owner on Jun 12, 2024. It is now read-only.

Fix for issue #431: Not all records are exported when calling DataGrid::buildCSV() #432

Merged
merged 1 commit into from
Jul 23, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 32 additions & 9 deletions src/DataSet.php
Original file line number Diff line number Diff line change
Expand Up @@ -182,10 +182,19 @@ public function build()
case "PDOStatement":
//orderby is handled by the code providing the PDOStatement

//calculate page variable.
$limit = $this->limit ? $this->limit : 100000;
$current_page = $this->url->value('page'.$this->cid, 0);
$offset = (max($current_page-1,0)) * $limit;
// Calculate page variable.
// $limit is set to only export a subset
if (isset($this->limit)) {
$limit = $this->limit;
$current_page = $this->url->value('page'.$this->cid, 0);
$offset = (max($current_page-1,0)) * $limit;
}
// $limit is null to export every records.
else {
$limit = null;
$current_page = 0;
$offset = 0;
}

$rows = array();
$skip = $cnt = 0;
Expand All @@ -195,11 +204,15 @@ public function build()
$skip++;
continue;
}
//gather the rows to render
elseif ($cnt <= $limit ) {
//gather the rows to render.
else {
$rows[$cnt] = $row;
$cnt++;
}
// If limit is set and we are passed it, break out of loop.
if (isset($limit) && ($cnt > $limit)) {
break;
}
}

$this->data = $rows;
Expand All @@ -226,9 +239,19 @@ public function build()
}
}

$limit = $this->limit ? $this->limit : 100000;
$current_page = $this->url->value('page'.$this->cid, 0);
$offset = (max($current_page-1,0)) * $limit;
// $limit is set to only export a subset
if (isset($this->limit)) {
$limit = $this->limit;
$current_page = $this->url->value('page'.$this->cid, 0);
$offset = (max($current_page-1,0)) * $limit;
}
// $limit is null to export every records.
else {
$limit = count($this->source);
$current_page = 0;
$offset = 0;
}

$this->data = array_slice($this->source, $offset, $limit);
$this->total_rows = count($this->source);
$this->paginator = new LengthAwarePaginator($this->data, $this->total_rows, $limit, $current_page,
Expand Down