Migration to 2.0
Migration to 2.0
Pandalex
Posts: 32Questions: 8Answers: 1
Hello,
Is there a way to convert my dom to the equivalent layout ?
dom: 'QBlfrtip'
Thanks
Alex
This question has accepted answers - jump to:
Answers
Try this:
See the
layout
docs for details of how the dom structure is laid out. See the basic examples for SearchBuilder and SearchPanes for steps to uselayout
to add these components.Kevin
Thanks, I was having trouble adding the button but I just need to add :
topStart: 'buttons'
I think I have one last issue with the migration.
I had the filter on top of each column but now I can't figure why I can't move them.
I can either:
- have the filter at the bottom and working
- have the filter at the top but no working
To move it I was doing
$('#tableau tfoot tr').appendTo('#tableau thead');
This is the my code right now :
@Pandalex There's nothing obvious there, could you link to an example, please. 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.
Colin
Hello @colin I tried to reproduce my issue in https://live.datatables.net/ but my data is generated trough an ajax call and I don"t know how to mimic that.
Since it's in Ajax, for the filter to work I need to put keyup in the init complete of the datatable configuration :
If I put it elsewhere the filters always return 0 data (I assume because the filters don't know what is in the table)
For this part :
$('#tableau tfoot tr').appendTo('#tableau thead');
1) If I don"t put it at all => The filter works, at the bottom
2) If I put it outside the datatables options => The filters come to the top but don't work
3) If I put it inside the initComplete => The filters don't come top and don't work
With Datables 1.1, the second way was working
I uploaded the debug : Your debug code is: erukah
I don't think DataTables 2 will like moving the footer to the header after initialisation. Do it before initialisation and it should work (tweaking the rest of your code to use the second row of the header for the filtering inputs of course).
DataTables makes a full "map" of the header and footer elements during initialisation now, so it can handle the colspan / rowspan of complex headers, and multiple rows. DataTables 1 wasn't so smart.
Allan
Thanks for your answer !
I tried different ways to aim at the seonde row but I'm not an HTML expert and it failed (I even tried to ask chatGPT)
Could you help me a bit more ?
will get you the second row in a
thead
.should be updates to:
Give that a whirl, and if no success, let me know, showing your latest code
Thanks,
Allan
Thank you so much for looking into it @allan
Where should I use this part ?
$("#tableau thead tr').eq(1);
If I use
$('#tableau tfoot tr').appendTo('#tableau thead');
outside the init I don't have my place holders but a second ligne with my row title
Right now my code is:
then
I tried changing the tfoot to a thead in the init complet but since the placeholder are not there it's not usefull
Won't work, since it is trying to select elements from the tfoot row, which you've just moved to the header.
Might work better for that.
Allan
Hmm it's the same, instead if the placeholders I get 2 titles row
Here is the full code, maybe my mistake is so obvious that you did not think it was a possibility ?
(if it helps the fixed column I can't make the fixed column works, it may be related ?)
The body contains the footer and header squeleton :
Here's how I would do it: https://live.datatables.net/tixoyeqo/1/edit (based on this example).
Here I just cloned the header - you could clone the footer, move the footer row or whatever.
Allan
It works !
Almost ... the placeholder are on top and I can filter but I have to issue with this way :
1) The main one is that I use colReoder, and the filter does not follow. So if I move a column all the filters after this one will filter the wrong column
I updated the test case :
https://live.datatables.net/tixoyeqo/3/edit
2) I was using class="fill" to avoid having wide columns with small size value (like the 'age column)
Where could I put it now ?
I tried adding it to the <th></th> like <th class="fill"></th> but no success
To add the class to the
input
do something like this:See if this thread helps with the ColReorder issue.
Kevin
Thanks you very much
The input tag is perfect.
My last issue is still the reorder.
I tried to mix this example from your thread with the previous test case, without success
I'm pretty sure that I don't get the correct index with this line:
let idx = [...th.parentNode.children].indexOf(th);
I tried to changed
let th = column.footer();
to
let th = column.header(1);
(and some other variations)
But it's not working
https://live.datatables.net/tixoyeqo/5/edit
In any case, thank you for all the help you already provided
You are getting this error:
Use
let api = this.api();
soapi
can be used in this statement:Updated test case:
https://live.datatables.net/tixoyeqo/6/edit
Kevin
You guys are great !
You solved everything, thanks a lot.
I'm trying to add a little tweak : I put 2 buttons as the first 2 columns.
Is there a way to hide the filters for those columns ?
If not, I'll just let the empy filter displayed
There are many ways to do this. See the
column-selector
docs for the options. You can specify an array of columns to apply the search inputs to. Or better is to use a class name. I updated the test case to assign the class nameno_search
to the columns to ignore. Then used the jQuery not() selector as thecolumn-selector
:api.columns(':not(.no_search)')
:https://live.datatables.net/tixoyeqo/8/edit
Kevin
Another option is to assign the class name using
columns.className
:https://live.datatables.net/tixoyeqo/9/edit
Kevin
It's perfect with the no search
You all are really great.
Skilled and helpful, you are wonderful human beings
Thank you