How to select all table rows (ajax)

How to select all table rows (ajax)

JenstelJenstel Posts: 14Questions: 4Answers: 0
edited July 2017 in Free community support

Hi.
I'm use ajax for datatable. How to select all table row?
$(table.rows( {search:'applied'} ).nodes()).addClass('active'); - selected only rows in curent page

Answers

  • bindridbindrid Posts: 730Questions: 0Answers: 119

    try $(table.rows( {search:'applied'} ).select();

  • JenstelJenstel Posts: 14Questions: 4Answers: 0

    Not working :(

  • bindridbindrid Posts: 730Questions: 0Answers: 119

    it works for me. http://jsbin.com/yifofu/edit?html,js,output

    I put "ai" in the search box, clicked on the select all button.
    The event handler for the button applied what is above and selected all rows.

    I cleared the search box, to see what was selected and was not on multiple pages.

  • JenstelJenstel Posts: 14Questions: 4Answers: 0

    I'm using

    $('#btn_allSelect').on("click", function(){ table.rows({search:'applied'}).select(); });

    and

    my.js:134 Uncaught TypeError: table.rows(...).select is not a function

  • tangerinetangerine Posts: 3,365Questions: 39Answers: 395

    @bindrid has enabled "select":

    var table = $('#example').DataTable( {
            data:dataset.data,
            select:"multi",
            "columns": myColumns
        } );
    

    Have you?

  • bindridbindrid Posts: 730Questions: 0Answers: 119

    thank you @tangerine, I meant to ask him that and that the select extenstion js and css files were included.

  • JenstelJenstel Posts: 14Questions: 4Answers: 0

    Help. I'm doing that
    var table = $('#example').DataTable( {
    data:dataset.data,
    select:"multi",
    "columns": myColumns
    } );
    but
    my.js:135 Uncaught TypeError: table.rows(...).select is not a function*

  • bindridbindrid Posts: 730Questions: 0Answers: 119

    Since the basic concept works as shown in my link, we are actually going to need to see more of your code, particularly your includes (both css and js) so we can figure out what is going on.

    https://datatables.net/manual/tech-notes/10 DataTables debugger provides information that we can use to figure out what is going on

This discussion has been closed.