Skip to content

Commit 731c7de

Browse files
committed
Add DataTable edit,delete,display Behaviors get/set
1 parent 727fe85 commit 731c7de

File tree

2 files changed

+36
-6
lines changed

2 files changed

+36
-6
lines changed

Ajax/semantic/widgets/datatable/DataTable.php

Lines changed: 33 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
use Ajax\semantic\html\collections\table\traits\TableTrait;
1414
use Ajax\semantic\html\collections\HtmlMessage;
1515
use Ajax\semantic\html\base\traits\BaseTrait;
16+
use Ubiquity\utils\base\UString;
1617

1718
/**
1819
* DataTable widget for displaying list of objects
@@ -63,13 +64,13 @@ public function run(JsUtils $js){
6364
if(\is_array($this->_editBehavior))
6465
$this->_generateBehavior("edit",$this->_editBehavior,$js);
6566
if(\is_array($this->_displayBehavior)){
66-
$this->_displayBehavior["jsCallback"]='$("#dataTable").hide();';
6767
$this->_generateBehavior("display",$this->_displayBehavior,$js);
6868
}
6969
parent::run($js);
70-
$this->_associateSearchFieldBehavior($js,$offset);
7170
if(isset($this->_pagination))
7271
$this->_associatePaginationBehavior($js,$offset);
72+
$this->_associateSearchFieldBehavior($js,$offset);
73+
7374
}
7475

7576
protected function _generateBehavior($op,$params,JsUtils $js){
@@ -219,13 +220,13 @@ protected function _generatePagination($table){
219220

220221
protected function _associatePaginationBehavior(JsUtils $js=NULL,$offset=null){
221222
if(isset($this->_urls["refresh"])){
222-
$this->_pagination->getMenu()->postOnClick($this->_urls["refresh"],"{'p':$(this).attr('data-page')}",$this->getRefreshSelector(),["preventDefault"=>false,"jqueryDone"=>"replaceWith","hasLoader"=>false,"jsCallback"=>'$("#'.$this->identifier.'").trigger("pageChange");$("#'.$this->identifier.'").trigger("activeRowChange");']);
223+
$this->_pagination->getMenu()->postOnClick($this->_urls["refresh"],"{'p':$(this).attr('data-page'),'_model':'".UString::doubleBackSlashes($this->_model)."'}",$this->getRefreshSelector(),["preventDefault"=>false,"jqueryDone"=>"replaceWith","hasLoader"=>false,"jsCallback"=>'$("#'.$this->identifier.'").trigger("pageChange");$("#'.$this->identifier.'").trigger("activeRowChange");']);
223224
}
224225
}
225226

226227
protected function _compileSearchFieldBehavior(JsUtils $js=NULL){
227228
if(isset($this->_searchField) && isset($js) && isset($this->_urls["refresh"])){
228-
$this->_searchField->postOn("change", $this->_urls["refresh"],"{'s':$(self).val()}","#".$this->identifier." tbody",["preventDefault"=>false,"jqueryDone"=>"replaceWith","hasLoader"=>"internal","jsCallback"=>'$("#'.$this->identifier.'").trigger("searchTerminate",[$(self).val()]);']);
229+
$this->_searchField->postOn("change", $this->_urls["refresh"],"{'s':$(self).val(),'_model':'".UString::doubleBackSlashes($this->_model)."'}","#".$this->identifier." tbody",["preventDefault"=>false,"jqueryDone"=>"replaceWith","hasLoader"=>"internal","jsCallback"=>'$("#'.$this->identifier.'").trigger("searchTerminate",[$(self).val()]);']);
229230
}
230231
}
231232
protected function _associateSearchFieldBehavior(JsUtils $js=NULL,$offset=null){
@@ -498,4 +499,32 @@ public function onActiveRowChange($jsCode){
498499
$this->getHtmlComponent()->onActiveRowChange($jsCode);
499500
return $this;
500501
}
502+
/**
503+
* @return mixed
504+
*/
505+
public function getDeleteBehavior() {
506+
return $this->_deleteBehavior;
507+
}
508+
509+
/**
510+
* @return mixed
511+
*/
512+
public function getEditBehavior() {
513+
return $this->_editBehavior;
514+
}
515+
516+
/**
517+
* @return mixed
518+
*/
519+
public function getDisplayBehavior() {
520+
return $this->_displayBehavior;
521+
}
522+
/**
523+
* @param mixed $_displayBehavior
524+
*/
525+
public function setDisplayBehavior($_displayBehavior) {
526+
$this->_displayBehavior = $_displayBehavior;
527+
}
528+
529+
501530
}

Ajax/semantic/widgets/datatable/JsonDataTable.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
use Ajax\common\html\BaseHtml;
77
use Ajax\service\AjaxCall;
88
use Ajax\JsUtils;
9+
use Ubiquity\utils\base\UString;
910

1011
/**
1112
* @author jc
@@ -58,7 +59,7 @@ protected function _associatePaginationBehavior(JsUtils $js=NULL,$offset=null){
5859
$callback.=$js->trigger("#".$id." [name='selection[]']","change",false)."$('#".$id." tbody .ui.checkbox').checkbox();".$js->execOn("change", "#".$id." [name='selection[]']", $this->_getCheckedChange($js));
5960
$callback.=$this->_generatePaginationScript($id);
6061
if(isset($this->_urls["refresh"])){
61-
$js->jsonArrayOn("click", "#".$menu->getIdentifier()." a","#".$this->_identifier." tr.".$this->_modelClass, $this->_urls["refresh"],"post",["params"=>"{'p':$(this).attr('data-page')}","jsCallback"=>$callback]);
62+
$js->jsonArrayOn("click", "#".$menu->getIdentifier()." a","#".$this->_identifier." tr.".$this->_modelClass, $this->_urls["refresh"],"post",["params"=>"{'p':$(this).attr('data-page'),'_model':'".UString::doubleBackSlashes($this->_model)."'}","jsCallback"=>$callback]);
6263
}
6364
}
6465

@@ -93,7 +94,7 @@ protected function _associateSearchFieldBehavior(JsUtils $js=NULL,$offset=null){
9394
$callback=$js->getScript($offset).$this->getHtmlComponent()->getInnerScript();
9495
$callback.=$js->trigger("#".$id." [name='selection[]']","change",false)."$('#".$id." tbody .ui.checkbox').checkbox();".$js->execOn("change", "#".$id." [name='selection[]']", $this->_getCheckedChange($js));
9596
$callback.="$('#pagination-{$id}').hide();$('#".$this->identifier."').trigger('searchTerminate',[$(self).val()]);";
96-
$js->jsonArrayOn("change", "#".$this->_searchField->getDataField()->getIdentifier(),"#".$this->_identifier." tr.".$this->_modelClass, $this->_urls["refresh"],"post",["params"=>"{'s':$(self).val()}","jsCallback"=>$callback]);
97+
$js->jsonArrayOn("change", "#".$this->_searchField->getDataField()->getIdentifier(),"#".$this->_identifier." tr.".$this->_modelClass, $this->_urls["refresh"],"post",["params"=>"{'s':$(self).val(),'_model':'".UString::doubleBackSlashes($this->_model)."'}","jsCallback"=>$callback]);
9798
}
9899
}
99100

0 commit comments

Comments
 (0)