Select all checkbox not working for non DOM sourced data
Select all checkbox not working for non DOM sourced data
![ruleboy21](https://secure.gravatar.com/avatar/e643fbb861983558c04c00ff83a38a2d/?default=https%3A%2F%2Fvanillicon.com%2Fe643fbb861983558c04c00ff83a38a2d_200.png&rating=g&size=120)
First, thanks for the great work you've been doing.
Whenever the table's data is sourced from any place other than the DOM, the select all checkbox does not work.
In the test case below, when the select all checkbox is clicked, only the rows on the first page are selected. Also, when you select a row on the current page and press shift+click
on a select checkbox on another page the same issue occurs again.
But when you first visit all the pages and then click on the select all checkbox, everything seems to work as it should.
Lastly, since the select checkbox is an actual checkbox now, can you remove the default styles so that it will use the default styles of the app or is there a way to remove the class dt-select-checkbox
from the select checkboxes.
Test Case: https://live.datatables.net/kasidece/1/edit
Thanks
This question has accepted answers - jump to:
Answers
Good one! Thanks for the test case. It isn't immediately apparent to me what is going wrong there. I'll try to look into it next week, but I'm travelling around a fair bit then, so it might be the following week I'm afraid.
edit It seems like it is related to
deferRender
. Disable that and it works fine (it is enabled by default in DataTables 2). I had thought I'd handled that in the code, but apparently not correctly!Allan
Thanks @allan it works after setting
deferRender
tofalse
. The issue is, I have about 20,000 rows in the table so changing it tofalse
negatively affects the performance. Is there a way to get it to work without settingdeferRender
to false?Thanks
Just stumbled upon the same problem, what are the chances that it's been reported today![:smile: :smile:](https://datatables.net/forums/resources/emoji/smile.png)
I disabled
deferRender
for now and it also seems to work on my side but it does seem to affect performance a little (my pc is a beast so not much problem here but I can guess some users might feel it more).Thanks for the awesome project no matter what! It's been a pleasure to work with it in the last years
(the migration to version 2 was not that trivial considering I had heavily customized DT in my app, but that's a "me" problem ahah :P)
I've just committed the fix. It will be in the nightly build soon, and it will be in the Select 2.0.1 release (that may or may not happen next week - I'll try to get it done, but circumstances might not make it easy!).
Thank you!
That means a lot.
Allan
Great. Thank you very much @allan
@allan thanks for the quick fix.
Now with
deferRender
enabled, when the select all checkbox is clicked, all the rows get selected as it should but only the checkboxes of the rows that are already created (mostly rows on the first page), get checked. Also when you select all, you can't deselect all.Kindly take a look at the test case below.
Thanks again.
Test Case: https://live.datatables.net/kasidece/4/edit
That is correct. I can't check a checkbox that hasn't been created yet
. Use
table.rows({selected: true})...
to get the rows which are selected, regardless of checkbox state.If you do need to have the actual checkboxes, then you have no choice but to disable
deferRender
.Doh! I can't believe I didn't check that - sorry! I've fixed it now and the nightly will rebuild soon.
Allan
Thanks for the fix.
I guess I will enable
deferRender
and then usecreatedRow
to manually check the checkbox if the row is selected.Thanks again @allan
The checkbox should get checked if the row has been created (which it will be if
deferRender
is disabled). Is that not happening? You shouldn't need to usecreatedRow
to do this.Allan
When
deferRender
is disabled everything works perfectly. But I'm dealing with large data so I can't disable it.I solved it by enabling
deferRender
, and then usedcreatedRow
to programmatically check the checkboxes if their parent rows are selected.Option 2 Since I'm using
table.rows({selected: true})
to select selected rows, I may switch back to fake checkboxes until I get a better solution that support actual checkboxes and enableddeferRender
.Thanks
I'm not understanding I'm afraid. As far as I can see, with the nightly build, the real checkboxes are working with
deferRender
enabled. Is that not the case for you? For example, use the check all header, and then go to the second page and it will show the checkboxes and rows on the second page as checked / selected. Is that not the case for you?Allan
Unfortunately when I click on the select all checkbox in the header and then go to the second page, the rows on the second page get selected but the checkboxes are not checked.
Please take a look at this test case: https://live.datatables.net/qesehomi/1/edit
Thanks
Yes, sorry. That is an error. I will get that sorted out.
Allan
This commit should sort it out!
Allan
Great. Thank you very much @allan
I'm having the same problem. I've tried the examples above and the header select checkbox doesn't show, whether or not deferRender is true or false.
I have just updated all my datatable versions and select versions and still not able to get the headerCheckbox to show.
I'm looking at the example: https://live.datatables.net/qesehomi/5/edit
I changed deferRender: false and still no header checkbox.
Might be a problem with the current nightly builds. I'll look into that. It works with the release: https://live.datatables.net/qesehomi/6/edit .
Allan