diff --git a/src/Datatable/Configuration.php b/src/Datatable/Configuration.php index eb2c2a0..7e8c8d0 100644 --- a/src/Datatable/Configuration.php +++ b/src/Datatable/Configuration.php @@ -65,6 +65,11 @@ class Configuration implements ArrayableInterface */ protected $dom; + /** + * @var array + */ + protected $order; + /** * @return string */ @@ -262,4 +267,22 @@ public function setDom(string $dom): Configuration $this->dom = $dom; return $this; } + + /** + * @return array|null + */ + public function getOrder(): ?array + { + return $this->order; + } + + /** + * @param array $order + * @return Configuration + */ + public function setOrder(array $order): Configuration + { + $this->order = $order; + return $this; + } } diff --git a/src/Datatable/Defaults/Configuration.php b/src/Datatable/Defaults/Configuration.php index 642551b..bfed237 100644 --- a/src/Datatable/Defaults/Configuration.php +++ b/src/Datatable/Defaults/Configuration.php @@ -22,5 +22,6 @@ public function __construct() $this->stateSave = true; $this->searching = true; $this->ordering = true; + $this->order = null; } } diff --git a/src/Datatable/Request10.php b/src/Datatable/Request10.php index 96c3399..69bc992 100644 --- a/src/Datatable/Request10.php +++ b/src/Datatable/Request10.php @@ -55,12 +55,14 @@ public function __construct(array $columns) } } - foreach ($_GET['order'] as $col) { - $i = $col['column']; + if (isset($_GET['order'])) { + foreach ($_GET['order'] as $col) { + $i = $col['column']; - if ($this->columns[$i]['sortBy']) { - $this->columns[$i]['sortDirection'] = $col['dir']; - $this->sort[] = [$this->columns[$i]['sortBy'], $col['dir']]; + if ($this->columns[$i]['sortBy']) { + $this->columns[$i]['sortDirection'] = $col['dir']; + $this->sort[] = [$this->columns[$i]['sortBy'], $col['dir']]; + } } } }