Skip to content

Commit 7ebf5fc

Browse files
committed
addFieldButtons
1 parent db4c081 commit 7ebf5fc

File tree

1 file changed

+24
-3
lines changed

1 file changed

+24
-3
lines changed

Ajax/semantic/widgets/datatable/DataTableFieldAsTrait.php

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
use Ajax\semantic\widgets\base\InstanceViewer;
55
use Ajax\semantic\html\base\HtmlSemDoubleElement;
66
use Ajax\common\html\BaseHtml;
7+
use Ajax\semantic\html\elements\HtmlButtonGroups;
78

89
/**
910
* trait used in DataTable
@@ -39,11 +40,12 @@ private function getCallable($thisCallback,$parameters,$callback=null){
3940
$object=call_user_func_array(array($this,$thisCallback), $parameters);
4041
if(isset($callback)){
4142
if(\is_callable($callback)){
42-
$callback($object,$instance);
43+
$callback($object,$instance,$this->_instanceViewer->count()+1);
4344
}
4445
}
4546
if($object instanceof HtmlSemDoubleElement){
46-
$object->setProperty("data-ajax",$this->_instanceViewer->getIdentifier());
47+
$id=$this->_instanceViewer->getIdentifier();
48+
$object->setProperty("data-ajax",$id);
4749
if($object->propertyContains("class","visibleover")){
4850
$this->_visibleHover=true;
4951
$object->setProperty("style","visibility:hidden;");
@@ -62,7 +64,14 @@ private function getFieldButton($caption,$visibleHover=true){
6264
$bt= new HtmlButton("",$caption);
6365
if($visibleHover)
6466
$this->_visibleOver($bt);
65-
return $bt;
67+
return $bt;
68+
}
69+
70+
private function getFieldButtons($buttons,$visibleHover=true){
71+
$bts=new HtmlButtonGroups("",$buttons);
72+
if($visibleHover)
73+
$this->_visibleOver($bts);
74+
return $bts;
6675
}
6776

6877
/**
@@ -101,6 +110,18 @@ public function addFieldButton($caption,$visibleHover=true,$callback=null){
101110
return $this;
102111
}
103112

113+
/**
114+
* Inserts a new ButtonGroups for each row
115+
* @param array $buttons
116+
* @param callable $callback
117+
* @param boolean $visibleHover
118+
* @return DataTable
119+
*/
120+
public function addFieldButtons($buttons,$visibleHover=true,$callback=null){
121+
$this->addField($this->getCallable("getFieldButtons",[$buttons,$visibleHover],$callback));
122+
return $this;
123+
}
124+
104125
/**
105126
* Inserts a new Button for each row at col $index
106127
* @param int $index

0 commit comments

Comments
 (0)