check box of other page is not disaplaying

check box of other page is not disaplaying

pravspravs Posts: 29Questions: 4Answers: 0

Hi,
when I select multiple check boxes on different pages, it only showing the values of the currently showing page.

For example, if I have 10 pages of data, and I select 2 check boxes from each page (totaling 20), only the values of 2 of the check boxes are getting

here is the code please help me
$('#allocate_btn').click(function(){

        var dataArr = [];
        $('#lead_table tr').filter(':has(:checkbox:checked)').each(function() {        
             dataArr.push($(this).find('td').eq(2).text());    
            console.log(dataArr);
        });

});  

Replies

  • bindridbindrid Posts: 730Questions: 0Answers: 119

    your code will only pull checkboxes from a visible page. You need to use the DataTables filter as shown here https://datatables.net/reference/api/filter()

  • pravspravs Posts: 29Questions: 4Answers: 0

    yes, but i want only the checked column rows in the link you refer i am unable to get the checked rows. it is showing error as
    Uncaught TypeError: :has(:checkbox:checked) is not a function..

    please help me to solve it

  • bindridbindrid Posts: 730Questions: 0Answers: 119

    Any reason why you are not using the "select" extension? It is built for this sort and thing and will get your selected rows with a single line of code.

  • pravspravs Posts: 29Questions: 4Answers: 0

    no nothing like that will you please explain what is this select functionality.

  • pravspravs Posts: 29Questions: 4Answers: 0

    and for me no need of row selection. On click of checkbox i want to get the row data thats why iam not prefering select.

  • pravspravs Posts: 29Questions: 4Answers: 0

    please help me on this i need it urgent

  • bindridbindrid Posts: 730Questions: 0Answers: 119

    What you are saying in your last two comments are at odds with your first comments.
    If you used the select extension as described here https://datatables.net/extensions/select/ then your clicks on the row to select it. Then, getting the selected rows is simple as

    var selectedRows = $('#lead_table").DataTable().rows({selected:true});

    or to get the data associated with each row:

    var rowData = $('#lead_table").DataTable().rows({selected:true}).data();

This discussion has been closed.