Skip to content

Commit 57c450b

Browse files
committed
Fix Pagination bug with groupByFields
1 parent 008e10b commit 57c450b

File tree

3 files changed

+17
-5
lines changed

3 files changed

+17
-5
lines changed

Ajax/common/BaseGui.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,4 +74,8 @@ public function compileHtml(JsUtils $js=NULL, &$view=NULL) {
7474
$htmlComponent->compile($js, $view);
7575
}
7676
}
77+
78+
public function matchHtmlComponents($callback){
79+
return array_filter($this->htmlComponents,$callback);
80+
}
7781
}

Ajax/semantic/traits/SemanticComponentsTrait.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,11 @@
1717
use Ajax\semantic\components\Tab;
1818
use Ajax\semantic\components\Shape;
1919
use Ajax\semantic\components\Form;
20-
use Ajax\JsUtils;
2120
use Ajax\semantic\components\SimpleSemExtComponent;
2221

2322
/**
2423
* @author jc
25-
* @property JsUtils $js
24+
* @property \Ajax\JsUtils $js
2625
*/
2726
trait SemanticComponentsTrait {
2827

Ajax/semantic/widgets/datatable/DataTable.php

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
use Ajax\semantic\html\base\traits\BaseTrait;
1616
use Ajax\service\JString;
1717
use Ajax\common\html\HtmlDoubleElement;
18+
use Ubiquity\utils\http\URequest;
1819

1920
/**
2021
* DataTable widget for displaying list of objects
@@ -167,12 +168,12 @@ protected function _generateContent($table){
167168
}
168169
InstanceViewer::setIndex(0);
169170
$fields=$this->_instanceViewer->getSimpleProperties();
170-
if(!is_array($this->_instanceViewer->getGroupByFields())){
171+
$groupByFields=$this->_instanceViewer->getGroupByFields();
172+
if(!is_array($groupByFields)){
171173
$table->fromDatabaseObjects($objects, function($instance) use($table,$fields){
172174
return $this->_generateRow($instance, $fields,$table);
173175
});
174176
}else{
175-
$groupByFields=$this->_instanceViewer->getGroupByFields();
176177
$activeValues=array_combine($groupByFields, array_fill(0, sizeof($groupByFields), null));
177178
$uuids=[];
178179
$table->fromDatabaseObjects($objects, function($instance) use($table,$fields,&$activeValues,$groupByFields,&$uuids){
@@ -262,7 +263,15 @@ protected function _generatePagination($table){
262263

263264
protected function _associatePaginationBehavior(JsUtils $js=NULL,$offset=null){
264265
if(isset($this->_urls["refresh"])){
265-
$this->_pagination->getMenu()->postOnClick($this->_urls["refresh"],"{'p':$(this).attr('data-page'),'_model':'".JString::doubleBackSlashes($this->_model)."'}",$this->getRefreshSelector(),["preventDefault"=>false,"jqueryDone"=>"replaceWith","hasLoader"=>false,"jsCallback"=>'$("#'.$this->identifier.'").trigger("pageChange");$("#'.$this->identifier.'").trigger("activeRowChange");']);
266+
$menu=$this->_pagination->getMenu();
267+
if(isset($menu) && isset($js)){
268+
$js->postOnClick("#".$menu->getIdentifier()." .item",$this->_urls["refresh"],"{'p':$(this).attr('data-page'),'_model':'".JString::doubleBackSlashes($this->_model)."'}",$this->getRefreshSelector(),["preventDefault"=>false,"jqueryDone"=>"replaceWith","hasLoader"=>false,"jsCallback"=>'$("#'.$this->identifier.'").trigger("pageChange");$("#'.$this->identifier.'").trigger("activeRowChange");']);
269+
$page=URequest::post("p");
270+
if(isset($page)){
271+
$js->execAtLast('$("#'.$this->getIdentifier().' .pagination").children("a.item").removeClass("active");$("#'.$this->getIdentifier().' .pagination").children("a.item[data-page='.$page.']:not(.no-active)").addClass("active");');
272+
}
273+
274+
}
266275
}
267276
}
268277

0 commit comments

Comments
 (0)