Select All Checkbox is updating even rows which are not filtered

Select All Checkbox is updating even rows which are not filtered

Sandeepbrungi7Sandeepbrungi7 Posts: 11Questions: 3Answers: 0

$('#selectAllMembers').on('click', function(){
var rows = table.rows({search: 'applied'}).nodes();
$('input[type="checkbox"]', rows).prop('checked', this.checked);
});
Using search functionality i'm filtering rows and selecting all filtered rows and applying some change. Change is applying to filtered rows + few rows which are not filtered

Answers

  • kthorngrenkthorngren Posts: 21,330Questions: 26Answers: 4,951

    I copied your code snippet into this test case:
    https://live.datatables.net/mehozinu/1/edit

    The code seems to work when searching the table, clicking Select All then clearing the search. Only those rows displayed when searching are checked.

    Please update the test case or tell us how to replicate the issue so we can help debug.

    Kevin

  • Sandeepbrungi7Sandeepbrungi7 Posts: 11Questions: 3Answers: 0

    For example:

    as per attached image..i am updating filtered record by selecting all checkbox option.Then it is updating correctly.
    When i remove search filter..all rows are getting this change

  • Sandeepbrungi7Sandeepbrungi7 Posts: 11Questions: 3Answers: 0

    when i clear 140 from the search box...all rows in the tables are effected with change made to this filter row

  • Sandeepbrungi7Sandeepbrungi7 Posts: 11Questions: 3Answers: 0

    var pageInfo = table.page.info();
    var pageNum = pageInfo.page;
    var rows= table.rows({ filter: 'applied' }).nodes();
    var newdata=[];
    var isPendselected=false;
    var isAbstractionStateMatched=false;
    _.each(rows.data(),function(rowData,index){
    if($(":checkbox:checked", $(rows[index])).prop('checked') ){}
    this is the code executing after select all checkbox

  • kthorngrenkthorngren Posts: 21,330Questions: 26Answers: 4,951

    There is nothing obvious in your code snippet. Please update my example or provide a test case showing the issue so we can help debug.

    Kevin

  • Sandeepbrungi7Sandeepbrungi7 Posts: 11Questions: 3Answers: 0

    after selecting filtered rows using select all checkbox..next a pop modal will open & display "Ok or Cancel button" the code provided in the link is after clicking on OK

  • kthorngrenkthorngren Posts: 21,330Questions: 26Answers: 4,951
    edited August 2023

    The test case doesn't run. Its getting a syntax error:

    Uncaught SyntaxError: Unexpected token '{'

    I still don't see anything obvious to cause the problem. Please update the test case so it runs and replicates the issue.

    Kevin

Sign In or Register to comment.