waldo2188 / DatatableBundle

Symfony2 Ajax Datatable Bundle to simplify the use of http://datatables.net/ (and Doctrine entity inside)
MIT License
17 stars 16 forks source link

Renderer and global search #21

Open janie24 opened 7 years ago

janie24 commented 7 years ago

Is it possible that the global search is not working on columns where I use a renderer? This is my Code:

`$query = $this->get('datatable') ->setEntity("AppBundle:Logs", "lg")
->setFields( array( "Modul" => 'lg.module', "Log" => 'lg.id', "Datum" => 'lg.when', // Declaration for fields: "Von" => 'lg.id', // "label" => "alias.field_attribute_for_dql" "identifier" => 'lg.id') // you have to put the identifier field without label. Do not replace the "identifier" )

                ->setWhere(                                                     // set your dql where statement
                     'lg.domain = :domain',
                     array('domain' => 'log')
                )

                //set a renderer for a specific column(index) 
                ->setRenderers(
                        array(
                            1 => array('view' => 'logs/renderers/log_renderer.html.twig'),
                            2 => array('view' => 'default/renderers/datetime.html.twig'),
                            3 => array('view' => 'logs/renderers/user.html.twig')
                        )
                )
                ->setOrder("lg.when", "desc")                                // it's also possible to set the default order
                ->setGlobalSearch(true);`

This is my log_renderer.html.twig for example: {{ dt_obj.message }} ({{ dt_obj.module }}) <br />Standort: {{ dt_obj.hierarchyId }} <br />{{dt_obj.user }} {{ dt_obj.when|date('d.m.Y H:i') }}

I have a renderer for 3 columns. The only global search that works is for the first column, where is no renderer. Any suggestions?

nacholibre commented 7 years ago

The rendered value is not searchable. When you search, SQL query is generated and ran to your database, the renders are not parsed.