1

On a page I have two classic report in different tabs.

I'm adding options: check all

eg.

In classic report query column

apex_item.checkbox2(1,country_id) checkbox_ID

On Heading column checkbox_ID

<input type="checkbox" id="checkAll" >

Function and Global Variable Declaration

$('#checkAll').click(function () { 
   $('input:checkbox').prop('checked', this.checked); 
});

Work fine on one classic report, but when add select option on second classic report after click on checkbox all item select all items in both classic report!

On second classic report I'm changing

<input type="checkbox" id="checkAll_TAB2" >

and

$('#checkAll_TAB2').click(function () { 
   $('input:checkbox').prop('checked', this.checked); 
});

Inspect element on page shows:

classic report 1

<input type="checkbox" name="f01" value="1">
<input type="checkbox" name="f01" value="2">

classic report 2

<input type="checkbox" name="f01" value="5">
<input type="checkbox" name="f01" value="6">

Any solutions?

cengiz sevimli
  • 1,461
  • 8
  • 19
user_odoo
  • 2,284
  • 34
  • 55

1 Answers1

3

The command $('input:checkbox').prop('checked', this.checked); will check all checkboxes on the page, not just the ones for the column that you clicked the header for.

One solution is to give each of the report regions a static id and use that in the function. For example I created 2 reports, one with static id 'EMP1', one with 'EMP2'. It works ok for me. If you have multiple columns with checkboxes you'll need another option.

$('#checkAll').click(function () { 
    //$('input:checkbox').prop('checked', this.checked); 
    $('#EMP1').find('input:checkbox').prop('checked', true);
});
$('#checkAll_TAB2').click(function () { 
    $('#EMP2').find('input:checkbox').prop('checked', true);
});
Koen Lostrie
  • 14,938
  • 2
  • 13
  • 19
  • Thanks for answer work fine! Do you have solution when use pagination when go to second page check_all not working. GL – user_odoo Nov 25 '22 at 13:30
  • 1
    Use a dynamic action (on click of the jquery selector) to execute the js instead of on page load. Make sure the scope is dynamic (or else it will only work on the 1st page). In any case, when you click "select all" it will only select the page that is currently visible. – Koen Lostrie Nov 25 '22 at 13:47
  • regarding the pagination challenge, you could also have a look APEX_COLLECTIONS... it is very useful for manipulating tables with js – Ulrik Larsen Jul 14 '23 at 12:24