0

I'm wondering how I can add a button (or a parent checkbox) to the following code to do Select All and Deselect All in the checkbox.

 function selectVols() { $("#volumesContainer").show(); $("#volumesContainer").dialog(); var tree = $('#tree').tree({ primaryKey: 'id', uiLibrary: 'bootstrap4', dataSource: menu, selectionType: 'multiple', checkboxes: true }); tree.on('checkboxChange', function (e, $node, record, state) { var vol; if (state != 'indeterminate') { $.each(volumes, function (i, e) { if (e.name == record.text) { vol = e; } }); if (vol != undefined) { if (state == 'checked') { draw(vol); } else { clear(vol); } } } }); 

I am very new to jquery and there seems to be many ways to do this on the Internet but none are close enough to the code I have been given to get a solution. Thank you!

1 Answer 1

1

Answer used here:

added the following above tree.on(

$('#treeCheckAll').on('click', function () { tree.checkAll(); }); $('#treeUncheckAll').on('click', function () { tree.uncheckAll(); }); 

along with the buttons

 <button id="treeCheckAll" class="gj-button-md">Check All</button> <button id="treeUncheckAll" class="gj-button-md">Uncheck All</button> 

could do tree.checkAll(); as a click event in the button too.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.