-
Notifications
You must be signed in to change notification settings - Fork 236
Error when searching (server side) #77
Comments
Is this still a problem? |
Unfortunately yes. |
Do you have the option "searchable" or "orderable" always set to false? Then the bundle throws an error. Just try at least one field with "searchable" = true or/and "orderable" = true. Or try the default settings. Please post your DataTables class. |
Thanks for your help. Here is my DataTables class: namespace PJM\AppBundle\Datatables;
use Sg\DatatablesBundle\Datatable\View\AbstractDatatableView;
use PJM\AppBundle\Twig\IntranetExtension;
/**
* Class HistoriqueDatatable
*
* @package PJM\AppBundle\Datatables
*/
class HistoriqueDatatable extends AbstractDatatableView
{
/**
* {@inheritdoc}
*/
public function buildDatatableView()
{
$this->getFeatures()
->setServerSide(true)
->setProcessing(true);
$this->getOptions()
->setOrder(array("column" => 0, "direction" => "desc"))
;
$this->getAjax()->setUrl($this->getRouter()->generate('pjm_app_consos_historiqueResults'));
$this->setStyle(self::BOOTSTRAP_3_STYLE);
$this->getColumnBuilder()
->add('date', 'datetime', array(
'title' => 'Date',
'format' => 'll'
))
->add('nombre', 'column', array('title' => 'Nombre',))
->add('item.libelle', 'column', array('title' => 'Item',))
->add('item.prix', 'column', array('title' => 'Prix',))
->add('item.boquette.nom', 'column', array('title' => 'Boquette',))
;
}
/**
* {@inheritdoc}
*/
public function getLineFormatter()
{
$ext = new IntranetExtension();
$formatter = function($line) use($ext) {
$line["nombre"] = $ext->nombreFilter($line["nombre"]);
$line["item"]["prix"] = $ext->prixFilter($line["nombre"]*$line["item"]["prix"]);
return $line;
};
return $formatter;
}
/**
* {@inheritdoc}
*/
public function getEntity()
{
return 'PJM\AppBundle\Entity\Historique';
}
/**
* {@inheritdoc}
*/
public function getName()
{
return 'historique_datatable';
}
} |
I can not reproduce the issue. Where does the problem occur (filename and line number)? Just try only the "date" field in your class. |
It occurs The error is still thrown with only the "date" field in my class. Here is the full stack trace :
|
I can't find an issue. Maybe something is in your entity class not mapped correctly. Clear your cache. |
I found what throws the error ! It is because I am setting parameters on the query builder, but the function setParameters clears the previous set parameters. That's a weird behaviour I didn't know of. // HistoriqueRepository.php
public function callbackFindByUser($user)
{
return function($qb) use($user) {
$qb
->join('Historique.user', 'u', 'WITH', 'u = :user')
->setParameters(array(
'user' => $user,
))
;
};
}
TL;DR : it is not a DataTables bug, but it may be good to notify devs in the doc about this ? |
Hello,
do any of you get a "Invalid parameter number: number of bound variables does not match number of tokens" error when using the search field ? I'm in serverside mode. It happens for all my datatables, even the simpliest.
Thanks,
Minishlink
The text was updated successfully, but these errors were encountered: