Skip to content
This repository was archived by the owner on May 14, 2022. It is now read-only.
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 12 additions & 5 deletions Datatables/Datatable.php
Original file line number Diff line number Diff line change
Expand Up @@ -680,13 +680,14 @@ public function setDefaultResultType($resultType)
return $this;
}

/**
/**
* Creates and executes the DataTables search, returns data in the requested format
*
* @param string The result type to use, should be one of: RESULT_JSON, RESULT_ARRAY, RESULT_RESPONSE
* @param $resultType string The result type to use, should be one of: RESULT_JSON, RESULT_ARRAY, RESULT_RESPONSE
* @param $callback function A callback function to allow the client to manipulate the row data in php
* @return mixed The DataTables data in the requested/default format
*/
public function getSearchResults($resultType = '')
public function getSearchResults($resultType = '', $callback=null)
{
if (empty($resultType) || !defined('self::RESULT_' . strtoupper($resultType))) {
$resultType = $this->defaultResultType;
Expand All @@ -698,9 +699,15 @@ public function getSearchResults($resultType = '')
$this->makeSearch();
$this->executeSearch();



if (is_callable($callback)){
$this->datatable['aaData'] = $callback($this->datatable['aaData']);
}

return call_user_func(array(
$this, 'getSearchResults' . $resultType
));
$this, 'getSearchResults' . $resultType
));
}

/**
Expand Down