[Advanced Bulk Selection] Refreshing the webblock, dosn't reset the bulk selection

Forge Component
Published on 2018-10-24 by Eduardo Jauch
5 votes
Published on 2018-10-24 by Eduardo Jauch

Hi, first of all I would like to thank the team that created this component. This component is just what needed in my case, to be able to bulk select eligible rows based on a attribute (status) of that row with using only a pre defined class and to enable or disable button(s) or link(s) automatically when a checkbox is checked or all checkboxed are unchecked.

There is one small bug I discovered while testing my application. When I tried to refresh the screen by using ajax refresh, it doesn't uncheck the bulk selection checkbox. This is because of the underlying variable val used by that bulk selection checkbox is still holding the last value, which is true. My suggestion is to add a preparation to the webblock and initialize the variable val to false. Therefore when the webblock is being ajax refresh, it will also uncheck the bulk selection checkbox.


Refreshing the table do not ALWAYS mean erase the selection. Keep it at the developer discretion is nicer.

Hi Maria I agreed with you. However if, after ajax refresh, at least one checkbox is not selected, then the bulk selection should be unchecked right. This is not the case when I tested it and I think that is the bug.

Hi Andrian, 

Well yes and no, if you uncheck one check box in the server side it should exists a action (or a parameter) to inform the "bulk selection" of that. But you would have to use that in your code any way. 

Hi Andrian and Maria,

I'll take a look at this problem and will try to devise a way to cope with it.

I'll come back here when I find a way to deal with this problem in a satisfactory way


Hi Eduardo and Maria,

Actually I already solved it. In the javascript code of this webblock, there is a function called checkBulkCheckboxIfAllSelected. This function will be executed when this webblock is being refresh and like the name says, it ONLY check if all checkboxes are selected and if that is the case, it will select the bulk selection. However if one checkbox is not selected, it will not uncheck the bulk selection. Therefore I added a code in that function that will also uncheck the bulk selection if there is at least one checkbox unselected. So the bulk selection will always be in sync with the individual checkboxes.

The only downside is that the name of the function checkBulkCheckboxIfAllSelected doesn't covered the new functionality. In my opinion it should be something like syncBulkSelectionWithCheckboxes. If you have a better idea, please share. Thanks a lot.


    var checkBulkCheckboxIfAllSelected = function() {
        var checkboxes = $("#" + TableRecordsWidget + " > tbody > tr > td input[type='checkbox']").filter("." + ClassToControl);
        var bulkSelectCheckbox = $("#" + chkboxId);
        var allChecked = true;

        if(checkboxes.length === 0) allChecked = false;
        checkboxes.each(function() {
            allChecked = allChecked && $(this)[0].checked;
        // remove bulk selection if at least one checkbox is not selected
        else {