Removing the countryName alias will kill the datatable entirely:
Undefined offset: 6 in [path]vendor/ali/datatable/Ali/DatatableBundle/Util/Datatable.php on line 134
A solution is to update the _addSearch function like this:
protected function _addSearch(\Doctrine\ORM\QueryBuilder $queryBuilder)
{
if ($this->search == TRUE)
{
$request = $this->request;
$search_fields = array_values($this->fields);
foreach ($search_fields as $i => $search_field)
{
if ($request->get("sSearch_{$i}"))
{
/* additions - if $search_field contains space use the first part */
$field = explode(' ',trim($search_field));
$search_field = $field[0];
/* end additions */
$queryBuilder->andWhere(" $search_field like '%{$request->get("sSearch_{$i}")}%' ");
}
}
}
}
I have a datatable that pulls data from several tables and since some fields have the same name I had to use aliases.
The datatable itself and the sorting part works but filtering doesn't. It uses the "fieldname AS alias" part in the WHERE condition:
My datatable definition looks like this:
Removing the countryName alias will kill the datatable entirely:
A solution is to update the _addSearch function like this: