Skip to content

Commit 154ceea

Browse files
authored
Merge pull request #33 from VictorOcio/feature/callback
feature/callback add config callback to execute function on datatable…
2 parents 54828a9 + 3d79032 commit 154ceea

File tree

2 files changed

+13
-3
lines changed

2 files changed

+13
-3
lines changed

src/Datatable/Datatable.php

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@
44

55
namespace CakeDC\Datatables\Datatable;
66

7-
use Cake\Core\InstanceConfigTrait;
8-
use Cake\Utility\Inflector;
9-
use Cake\Utility\Text;
107
use CakeDC\Datatables\Datatables;
118
use CakeDC\Datatables\Exception\MissConfiguredException;
129
use CakeDC\Datatables\View\LinkFormatter\LinkInterface;
10+
use Cake\Core\InstanceConfigTrait;
11+
use Cake\Utility\Inflector;
12+
use Cake\Utility\Text;
1313
use Exception;
1414
use InvalidArgumentException;
1515

@@ -477,6 +477,11 @@ public function getDatatableScript(): string
477477
);
478478
}
479479

480+
public function setCallback($callback): void
481+
{
482+
$this->setConfig('drawCallback', $callback);
483+
}
484+
480485
public function getCommonScript(): string
481486
{
482487
return 'console.log("from getCommonScript")';

src/View/Helper/DatatableHelper.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,4 +164,9 @@ public function getTableHeaders(
164164
->getTableHeaders();
165165
}
166166

167+
public function setCallback(string $functionCallback)
168+
{
169+
$this->dtInstance->setCallback($functionCallback);
170+
}
171+
167172
}

0 commit comments

Comments
 (0)