try to use DT for select list

try to use DT for select list

azfrankazfrank Posts: 6Questions: 2Answers: 0

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

  • azfrankazfrank Posts: 6Questions: 2Answers: 0

    I'm sorry, forgotten: Browser IE9 +

  • allanallan Posts: 63,121Questions: 1Answers: 10,397 Site admin
    Answer ✓

    Use the rows().select() and rows().deselect() methods to select and deselect rows rather than adding or removing classes yourself: https://jsfiddle.net/jv9y7wzs/7/ .

    Allan

  • azfrankazfrank Posts: 6Questions: 2Answers: 0

    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/

    • the button text and the title-tag contains the selected values.

    regards,
    azfrank

  • azfrankazfrank Posts: 6Questions: 2Answers: 0

    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

  • allanallan Posts: 63,121Questions: 1Answers: 10,397 Site admin

    I'm just wondering why the "select all" row is not selected

    Because it was being selected by the rows().select() call, and then deselected by the click event that was still active on it! Possibly calling stopPropagation 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

This discussion has been closed.