Git Product home page Git Product logo

Comments (8)

stwe avatar stwe commented on May 24, 2024

Is this still a problem?

from datatablesbundle.

Minishlink avatar Minishlink commented on May 24, 2024

Unfortunately yes.
I can use the datatable well if I only use the sort function or change the page length, or use the paginator.
But as soon as I use the search function once, any interaction (sort, page length, search etc..) throws me a 500 error "Invalid parameter number: number of bound variables does not match number of tokens"...

from datatablesbundle.

stwe avatar stwe commented on May 24, 2024

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.

from datatablesbundle.

Minishlink avatar Minishlink commented on May 24, 2024

Thanks for your help.
My settings are the default settings. Unfortunately, adding one field searchable or orderable still throws the error... I also tried forcing searching and ordering in the features with no success.

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';
    }
}

from datatablesbundle.

stwe avatar stwe commented on May 24, 2024

I can not reproduce the issue. Where does the problem occur (filename and line number)?

Just try only the "date" field in your class.

from datatablesbundle.

Minishlink avatar Minishlink commented on May 24, 2024

It occurs
at Paginator ->getIterator () in vendor/sg/datatablesbundle/Sg/DatatablesBundle/Datatable/Data/DatatableData.php at line 407

The error is still thrown with only the "date" field in my class.

Here is the full stack trace :

[1] Doctrine\ORM\Query\QueryException: Invalid parameter number: number of bound variables does not match number of tokens
    at n/a
        in C:\Users\Louis\Documents\Programmation\Sites\pjm-intranet\vendor\doctrine\orm\lib\Doctrine\ORM\Query\QueryException.php line 100

    at Doctrine\ORM\Query\QueryException::invalidParameterNumber()
        in C:\Users\Louis\Documents\Programmation\Sites\pjm-intranet\vendor\doctrine\orm\lib\Doctrine\ORM\Query.php line 281

    at Doctrine\ORM\Query->_doExecute()
        in C:\Users\Louis\Documents\Programmation\Sites\pjm-intranet\vendor\doctrine\orm\lib\Doctrine\ORM\AbstractQuery.php line 794

    at Doctrine\ORM\AbstractQuery->execute(null, '3')
        in C:\Users\Louis\Documents\Programmation\Sites\pjm-intranet\vendor\doctrine\orm\lib\Doctrine\ORM\AbstractQuery.php line 598

    at Doctrine\ORM\AbstractQuery->getScalarResult()
        in C:\Users\Louis\Documents\Programmation\Sites\pjm-intranet\vendor\doctrine\orm\lib\Doctrine\ORM\Tools\Pagination\Paginator.php line 151

    at Doctrine\ORM\Tools\Pagination\Paginator->getIterator()
        in C:\Users\Louis\Documents\Programmation\Sites\pjm-intranet\vendor\sg\datatablesbundle\Sg\DatatablesBundle\Datatable\Data\DatatableData.php line 407

    at Sg\DatatablesBundle\Datatable\Data\DatatableData->getResponse()
        in C:\Users\Louis\Documents\Programmation\Sites\pjm-intranet\src\PJM\AppBundle\Controller\ConsosController.php line 28

    at PJM\AppBundle\Controller\ConsosController->historiqueResultsAction()
        in  line 

    at call_user_func_array(array(object(ConsosController), 'historiqueResultsAction'), array())
        in C:\Users\Louis\Documents\Programmation\Sites\pjm-intranet\app\bootstrap.php.cache line 3008

    at Symfony\Component\HttpKernel\HttpKernel->handleRaw(object(Request), '1')
        in C:\Users\Louis\Documents\Programmation\Sites\pjm-intranet\app\bootstrap.php.cache line 2970

    at Symfony\Component\HttpKernel\HttpKernel->handle(object(Request), '1', true)
        in C:\Users\Louis\Documents\Programmation\Sites\pjm-intranet\app\bootstrap.php.cache line 3119

    at Symfony\Component\HttpKernel\DependencyInjection\ContainerAwareHttpKernel->handle(object(Request), '1', true)
        in C:\Users\Louis\Documents\Programmation\Sites\pjm-intranet\app\bootstrap.php.cache line 2364

    at Symfony\Component\HttpKernel\Kernel->handle(object(Request))
        in C:\Users\Louis\Documents\Programmation\Sites\pjm-intranet\web\app_dev.php line 28

from datatablesbundle.

stwe avatar stwe commented on May 24, 2024

I can't find an issue. Maybe something is in your entity class not mapped correctly. Clear your cache.

from datatablesbundle.

Minishlink avatar Minishlink commented on May 24, 2024

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,
            ))
        ;
    };
}

setParameters is to be replaced by setParameter

TL;DR : it is not a DataTables bug, but it may be good to notify devs in the doc about this ?

from datatablesbundle.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.