Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
65
Select all
posted

Hello,

How can i do this with combo:

I have combo box with multiSelection: "onWithCheckboxes" and one button "Select all" .

On button click , all checkboxes  need to be selected and combo text need to be (ALL). 

Thank you in advance

BR Sergej

 

Parents
No Data
Reply
  • 11095
    Offline posted

    Hello Sergej,

    Thank you for contacting Infragistics Developer Support!

    Thins can be achieved by using the dataSource option getter and selecting all values from dataSource using values method.

     1
     2
     3
     4
     5
     6
     7
     8
     9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    
    $(function() {
    	var dataSource = [
    		{'id': 1, 'country': 'El Salvador'},
    		{'id': 2, 'country': 'United States of America'},
    		{'id': 3, 'country': 'Djibouti'},
    		{'id': 4, 'country': 'Botswana'},
    		{'id': 5, 'country': 'Mali'},
    		{'id': 6, 'country': 'Japan'},
    		{'id': 7, 'country': 'Marshall Islands'},
    		{'id': 8, 'country': 'Qatar'},
    		{'id': 9, 'country': 'Moldova'},
    		{'id': 10, 'country': 'Argentina'}
    	];
    
    	$('#combo').igCombo({
    		dataSource: dataSource,
    		valueKey: 'id',
    		textKey: 'country',
    		multiSelection : 'onWithCheckboxes'
    	});
    
    	$('#select-all-from-combo').on('click', function() {
    		var $combo = $('#combo');
    		var dataSource = $combo.igCombo('option', 'dataSource');
    		var values = [];
    
    		dataSource.forEach(function(element, index, array) {
    			values.push(element['id']);
    		});
    
    		$combo.igCombo('values', values);
    	});
    });
    

    Please review the attached sample and let me know if you have any additional questions.

    igCombo-multiple-selection-with-checkboxes-select-all.zip
Children