Header checbox for select all don't work with select2
Header checbox for select all don't work with select2
kevin_sc
Posts: 5Questions: 2Answers: 0
Hello can you help me please ?
I use select2 with datatable
return new DataTable(`#${tableName}`, {
scrollX: true,
responsive:true,
destroy: true,
autoWidth: true,
serverSide: serverSide,
searching: false,
processing: true,
language: dataTablesFr,
ajax: dataToPost,
columnDefs: columnDefinition,
paging: true,
dom: 't<"bottom"<"data-table-pagination-footer"ilp>',
select: {
style: 'os',
selector: 'td:first-child',
headerCheckbox: true
}
});
const dataTable = DataTableEditorSetting.create(
tableName,
dataToAjax,
[
{
orderable: false,
render: DataTables.render.select(),
targets: 0
},
and i have a <th></th> my datatatble work well but no checkbox header to select all
<th data-dt-column="0" rowspan="1" colspan="1" class="dt-orderable-none dt-ordering-asc" aria-sort="ascending" aria-label=""><span class="dt-column-title"></span><span class="dt-column-order"></span></th>
I dont find why, have you idea please ?
Answers
How are you using select2 with Datatables?
Are you suing Select 2.0.0 which is when this feature was added?
This [example[(https://www.datatables.net/extensions/select/examples/checkbox/checkbox.html) works. The
select.headerCheckbox
option is set totrue
by default so you shouldn't need to useheaderCheckbox: true
.Please post a link to your page or a test case replicating the issue so we can help debug.
https://www.datatables.net/manual/tech-notes/10#How-to-provide-a-test-case
Kevin
Thanks for you help
I use in my package json
"datatables.net-select": "^2.0.0",
In my class datatable
and i use
I tried debuger but
in my js i have when my datatble is load
Thanks
Edited by Kevin: Syntax highlighting. Details on how to highlight code using markdown can be found in this guide
I'm not familiar with
DataTableEditorSetting.create()
. Im' guessing it initializes the Editor. You have this in that method:This is a Datatables config not an Editor config. You probably will need to remove it from the
DataTableEditorSetting.create()
code and place it in the Datatables init code like this example.Kevin
It's just a js class
export default DataTableEditorSetting;`
the table
Always same problem
but the column header is curious
<span class="dt-column-title"></span><span class="dt-column-order"></span>
Thanks and sorry
Edited by Kevin: Syntax highlighting. Details on how to highlight code using markdown can be found in this guide
There is nothing obvious in your code. Please post a link to your page or a test case replicating the issue so we can help debug.
https://www.datatables.net/manual/tech-notes/10#How-to-provide-a-test-case
Kevin
Finally i use custom selectbox and javascript event
It might not be relevant, but I've got a very similiar instance where the header checkbox doesn't appear.
Curiously one one place in the application it does, and in one place it doesn't. The only difference in terms of configuration between the two is that one has pre-rendered data in the table itself and the other is dynamically populated via ajax and setting the .data(). Is it possible that when it's done dynamically datatables isn't adding the header checkbox?
(We are using DataTables 2.0.8 and the other latest versions of the extensions)
@chris.durham
Here is an example of an ajax loaded Datatable with the select all checkbox in the header:
https://live.datatables.net/cirazoqu/1/edit
Can you provide a test case showing the issue you are having so we can help debug?
https://www.datatables.net/manual/tech-notes/10#How-to-provide-a-test-case
Kevin
@kthorngren
I followed the advice on a different thread and added className: 'dt-select' to my columns:{} definition for the first column and that solved it, so I think it's something that @allan is aware of..