|
15 | 15 | use Ajax\semantic\html\base\traits\BaseTrait; |
16 | 16 | use Ajax\service\JString; |
17 | 17 | use Ajax\common\html\HtmlDoubleElement; |
| 18 | +use Ubiquity\utils\http\URequest; |
18 | 19 |
|
19 | 20 | /** |
20 | 21 | * DataTable widget for displaying list of objects |
@@ -167,12 +168,12 @@ protected function _generateContent($table){ |
167 | 168 | } |
168 | 169 | InstanceViewer::setIndex(0); |
169 | 170 | $fields=$this->_instanceViewer->getSimpleProperties(); |
170 | | - if(!is_array($this->_instanceViewer->getGroupByFields())){ |
| 171 | + $groupByFields=$this->_instanceViewer->getGroupByFields(); |
| 172 | + if(!is_array($groupByFields)){ |
171 | 173 | $table->fromDatabaseObjects($objects, function($instance) use($table,$fields){ |
172 | 174 | return $this->_generateRow($instance, $fields,$table); |
173 | 175 | }); |
174 | 176 | }else{ |
175 | | - $groupByFields=$this->_instanceViewer->getGroupByFields(); |
176 | 177 | $activeValues=array_combine($groupByFields, array_fill(0, sizeof($groupByFields), null)); |
177 | 178 | $uuids=[]; |
178 | 179 | $table->fromDatabaseObjects($objects, function($instance) use($table,$fields,&$activeValues,$groupByFields,&$uuids){ |
@@ -262,7 +263,15 @@ protected function _generatePagination($table){ |
262 | 263 |
|
263 | 264 | protected function _associatePaginationBehavior(JsUtils $js=NULL,$offset=null){ |
264 | 265 | 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 | + } |
266 | 275 | } |
267 | 276 | } |
268 | 277 |
|
|
0 commit comments