no change in column search with symfony orm
no change in column search with symfony orm

hi all
I 'm trying to get - every column search - for a list of entity in Symfony 4 ,
in this part of code :
// Apply the search
table.columns().every( function ()
{
var that = this;
$( 'input', this.footer() ).on( 'keyup change clear', function ()
{
console.log('result ', that.search( this.value ).draw());
//** in the console **: result = v [Array(1), context: Array(1), selector: {…}, tables: ƒ, table: ƒ, draw: ƒ, …]
console.log('condition = ',that.search() !== this.value );
// **in the console **: condition = true
if ( that.search() !== this.value )
{
that
.search( this.value )
.draw();
}
} );
} );
it looks like everything 's fine but there 's no change in my page.
Can somebody help please ?
thanks
This discussion has been closed.
Answers
Hi @ng.somchith ,
It might be a timing issue. Are you creating the
input
elements in theinitComplete
?If not, we're happy to take a look, but as per the forum rules, please link to a test case - a test case that replicates the issue will ensure you'll get a quick and accurate response. Information on how to create a test case (if you aren't able to link to the page you are working on) is available here.
Cheers,
Colin
HI Colin
thanks very much for your answer.
I 'm new and don't know yet how to create a test case.
So I have create my first GitHUB for this here :
https://github.com/ngsomchith/symfony-datatable-orm
hope you can help
thanks
Ng.Somchith
Hi @ng.somchith ,
Thanks for the code, I wouldn't know what to do with it, I'm afraid. Are you able to link to your page?
Cheers,
Colin
hi Colin
I 've only use symfony in local.
I check how to upload it and come back later .
thanks
hi Colin
I have mad it
here is my link :
http://s751326739.onlinehome.fr/symfony4/datatablesqlite/public/#
If you can help me to find out how to resolve it
Thanks very very much
Somchith NGUYEN
Thanks for the link. The problem is that you are adding the table footer element (and cells) after the table has been initialised. So
column().footer()
isn't going to return anything since DataTables doesn't know about the footer element (it wasn't present when initialised and isn't picked up dynamically).You need to add the footer cells before initialising the DataTable. That looks a little tricky in this case since you are dynamically loading the table configuration, including the columns.
As such, I'd suggest that you add the event handler here:
e.g. you could do:
That said, this will not work with column visibility. If you hide any columns this will break since, again, DataTables doesn't know about the footer so it won't hide the cells.
Allan
hi Colin
Thanks very much for the answer .
I think I can work it out with your remark.
I 'll come back when I ' ll can make it
Somchith
thenks Allans
sorry
hi Colin and Allans
Thanks you very much to you 2
I 've made it .
here is the link
http://s751326739.onlinehome.fr/symfony4/datatable_orm_sqlite/public/
Somchith NGUYEN
Hi @ng.somchith ,
That appears to be working for me - any value entered in the footer's
input
elements filters as expected. Could you give steps to reproduce, please.Cheers,
Colin
hi Colin
here is my function =
my link is moved to
http://s751326739.onlinehome.fr/symfony4/datatable_orm_sqlite0/public/
That still appears to be working for me - any value entered in the footer's
input
elements filters as expected. Could you give steps to reproduce, please.hi colin
these are my steps : tell me in which step you need details
1) create symfony project
2) create entity
// in this function
3) import data in $(#example)
4) create his tfoot by his children $('#td tfoot')
5) duplicate to $('#dt2')
6) create $('#dt2 tfoot th ')
7) and finally, create $('#dt2').DataTable()
Somchith NGUYEN
I meant how can I reproduce the issue on http://s751326739.onlinehome.fr/symfony4/datatable_orm_sqlite0/public/ ... As I've said many times, those searches are behaving as expected to me.
hi Colin,
I upload my html and my Controller, So I think you 'll be able to reproduce it,
heres 's my entity
<?php
namespace App\Entity;
use Doctrine\ORM\Mapping as ORM;
/**
* @ORM\Entity(repositoryClass="App\Repository\ArticleRepository")
*/
class Article
{
public function __construct(){
$this->unite = 'pce';
$this->stockmin = 3;
}
}
and the controller :
<?php
namespace App\Controller;
use App\Entity\Article;
use Symfony\Component\HttpFoundation\Request;
use Omines\DataTablesBundle\Column\TextColumn;
use Symfony\Component\Routing\Annotation\Route;
use Omines\DataTablesBundle\Controller\DataTablesTrait;
use Omines\DataTablesBundle\Adapter\Doctrine\ORMAdapter;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
class DatatableController extends Controller
{
/**
* @Route("/")
*/
use DataTablesTrait;
public function showAction( Request $request)
{
$table = $this->createDataTable()
->add('ref', TextColumn::class, ['label' => 'ref', 'className' => 'bold'])
->add('designation', TextColumn::class, ['label' => 'Désignation', 'className' => 'bold'])
->add('stockmin', TextColumn::class, ['label' => 'Stock critique', 'className' => 'bold'])
->add('prixu', TextColumn::class, ['label' => 'prix U.', 'className' => 'bold'])
->add('qte', TextColumn::class, ['label' => 'qte dispo.', 'className' => 'bold'])
//->add('company', TextColumn::class, ['field' => 'company.name'])
}
}
and my HTML with his script
<link rel="stylesheet" type="text/css"
href="https://cdn.datatables.net/v/dt/jq-3.2.1/dt-1.10.16/datatables.min.css"/>
<link rel="alternate" type="application/rss+xml" title="RSS 2.0" href="http://www.datatables.net/rss.xml">
Hope this can help
Somchith NGUYEN