Bulk Select for Multiple checkboxes per row.

Bulk Select for Multiple checkboxes per row.

  
Hello,

I'm wondering if there is a way to get the List_BulkSelect to work when you have more than one Checkbox per row in a table. Ideally, I would like two separate List_BulkSelect widgets to control the two separate checkboxes independently.


Has anyone done this? Is it possible with BulkSelect or will I need to figure something out on my own using javascript?

Thanks
Hello Leo,

With the listbulk select it wouldn't be possible (the JS will select all checkboxes in the table).

Think you best can take a look at the listbulk select JS and change it to your own needs.

Kind regards,
Evert
Hi,
 
You just need to copy/paste RichWidgets webblock and paste following code on its javascript.
 
It will only work for checkboxes on the first column.

var RichWidgets_List_BulkSelect_toggle = null;

function RichWidgets_List_BulkSelect_bootstrap(chkboxId, TableRecordsWidget, ButtonWidgetsList) {
  $(function($) {
  
  //enable disable buttons
   var RichWidgets_List_BulkSelect_toggleEnabledButtons = function() {
    $.each(ButtonWidgetsList.split(','),  function(i, val) {
      if (val != "") {
        var obj = $('#' + val);
        if ($('#' + TableRecordsWidget +' tbody tr td:first-child').find(":checkbox:checked").length==0){
          obj.attr('disabled', 'disabled');
          if (obj.attr('href') != undefined  && obj.attr('href') != '') {
            obj.data('hrefSave',obj.attr('href'));
            obj.removeAttr('href');
          }
          if (obj.attr('onclick') != undefined) {
            if (obj.data('clickFn') == undefined)
              obj.data('clickFn', new Function(obj.attr('onclick')));
          }
          obj.unbind('click.BulkSelect');
          obj.removeAttr('onclick');
        }
        else {
          obj.removeAttr('disabled')
          if (obj.data('hrefSave') != undefined) {
            obj.attr('href',obj.data('hrefSave'));
          }
          if (obj.data('clickFn') != undefined) {
            obj.unbind('click.BulkSelect');
            obj.bind('click.BulkSelect', obj.data('clickFn'));
          }
        }
        obj = null;
      }
    });
    $('#' + TableRecordsWidget + ' tbody ').find('tr:has(:checkbox:not(:checked))').removeClass('TableRecords_SelectedLine');
    $('#' + TableRecordsWidget + ' tbody ').find('tr:has(:checked)').addClass('TableRecords_SelectedLine');
    
  };
  
  RichWidgets_List_BulkSelect_toggle = RichWidgets_List_BulkSelect_toggleEnabledButtons;

    RichWidgets_List_BulkSelect_toggleEnabledButtons();
    
    //click on bulk select
    $('#' + chkboxId).click(function(){
        var bulkChecked = $('#' + chkboxId).attr('checked');
        $('#' + TableRecordsWidget).find("tbody tr td:first-child").find('input:checkbox').each(function() {
            var boxChecked = $(this).attr('checked');
            if (bulkChecked) {
                if(!boxChecked) {
                    if(typeof $(this)[0].onclick == "function")
                        $(this)[0].click();
                    else
                        $(this).attr('checked',true);
                }
            }
            else {
                if(boxChecked) {
                    if(typeof $(this)[0].onclick == "function")
                        $(this)[0].click();
                    else
                        $(this).attr('checked',false);
                }
            }
        });
        RichWidgets_List_BulkSelect_toggleEnabledButtons();
    });
    
    //click on individual checkboxes
    $('#' + TableRecordsWidget +' tbody tr td:first-child').find(':checkbox').click(function(){
     RichWidgets_List_BulkSelect_toggleEnabledButtons();
    });
  });
 }