DatatableBundle icon indicating copy to clipboard operation
DatatableBundle copied to clipboard

Renderer and global search

Open janie24 opened this issue 7 years ago • 1 comments

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?

janie24 avatar Apr 25 '17 12:04 janie24

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

nacholibre avatar May 31 '17 11:05 nacholibre