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