try to use DT for select list
try to use DT for select list
hi to all,
in my shop it is VERY restrictive to pass new libraries in production, so I have to take what we already have:
datatables 1.10.12, datatables.select 1.2.0, jQuery 1.12.3-
I just tried to create a kind of select list, my approach was this
What I want to achieve is:
- User clicks on search field
- Dropdown list with table content appears (works)
- multiple select (works)
- when first item (select all) is selected, all other searched rows should be selected (DOES NOT WORK), I tried with class, type=Input, nothing works. tried several Solutions from Google.
- and I want to get the Dropdown list closed when the Focus is out of my div "selName" .DOES NOT WORK. tried several Solutions from Google.
Is there any other way (with the libraries on top of my posting) I can achieve this?
thank you very much in advance,
regards,
azfrank
This question has an accepted answers - jump to answer
Answers
I'm sorry, forgotten: Browser IE9 +
Use the
rows().select()
androws().deselect()
methods to select and deselect rows rather than adding or removing classes yourself: https://jsfiddle.net/jv9y7wzs/7/ .Allan
allan, thank you very much,
i'm getting further and further....
I'm just wondering why the "select all" row is not selected
BTW: I already solved my "out of Focus" Problem:
https://jsfiddle.net/defaz/obzx9msh/1/
regards,
azfrank
here's a new fiddle with select/deselect all.
I'm very new to datatables/jquery/"web programming" at all.
If somebody has some hints to improve/simplify my code: you are VERY welcome.
azfrank
Because it was being selected by the
rows().select()
call, and then deselected by the click event that was still active on it! Possibly callingstopPropagation
might have resolved that, however, I think a checkbox outside of the DataTable is probably a better way to do it, as you have done.Allan