diff --git a/forms/ComplexTableField.php b/forms/ComplexTableField.php index dd486ed91..4722de28b 100755 --- a/forms/ComplexTableField.php +++ b/forms/ComplexTableField.php @@ -200,10 +200,15 @@ JS; $SQL_start = intval($_REQUEST['ctf'][$this->Name()]['start']); $limitClause .= " OFFSET {$SQL_start}"; } + + $sort = $this->sourceSort; + if(isset($_REQUEST['ctf'][$this->Name()]['sort'])) { + $sort = Convert::raw2sql($_REQUEST['ctf'][$this->Name()]['sort']); + } - $sourceItems = DataObject::get($this->sourceClass, $this->sourceFilter, $this->sourceSort, $this->sourceJoin, $limitClause); + $sourceItems = DataObject::get($this->sourceClass, $this->sourceFilter, $sort, $this->sourceJoin, $limitClause); - $this->unpagedSourceItems = DataObject::get($this->sourceClass, $this->sourceFilter, $this->sourceSort, $this->sourceJoin); + $this->unpagedSourceItems = DataObject::get($this->sourceClass, $sort, $this->sourceSort, $this->sourceJoin); $this->totalCount = ($this->unpagedSourceItems) ? $this->unpagedSourceItems->TotalItems() : null; diff --git a/javascript/TableListField.js b/javascript/TableListField.js index ff8800606..c9d9a62b4 100755 --- a/javascript/TableListField.js +++ b/javascript/TableListField.js @@ -12,6 +12,10 @@ TableListField.prototype = { onclick: this.deleteRecord.bind(this) }; + rules['#'+this.id+' th a'] = { + onclick: this.paginate.bind(this) + }; + rules['#'+this.id+' th'] = { initialize: function() { var sortLinks = $$('span.sortLinkHidden a', this); @@ -269,4 +273,4 @@ TableListRecord.prototype = { } //TableListRecord.applyTo('div.TableListField tr'); -TableListField.applyTo('div.TableListField'); \ No newline at end of file +TableListField.applyTo('div.TableListField');