“Select All” checkbox in transaction services RSD

Since transaction services option is still only available in RSD (and hopefully will be soon in dossiers), we still find the best workarounds to add missing and needed functionality. Imagine you have created a document with 20 checkboxes to mark entries which will be submitted to the database and you want to select them all at once instead of clicking on them one by one. This option is available out of the box when our entries are displayed in grid, but what happens in case when each checkbox is placed in the separate section and we do not want the end user to perform the click operation 20 times?

In our example we have 5 separate sections: 4 transactions configured on panels and 1 transaction on grid. The checkboxes are marked with the blue rectangles. On the very top we have another blue rectangle, which marks our “select all” javascript placed in the HTML container. Below you can find the script, which is ready to be pasted into your HTML container on the document:

<script>
document.getElementById(‘selectAll’).onclick = function(){
if(this.checked) {
var checkboxes = document.getElementsByClassName(‘mstrmojo-Label tristate’);
for (var checkbox of checkboxes) {
if(checkbox.className == ‘mstrmojo-Label tristate’) {
checkbox.click();}
}
}else{
var elems = document.getElementsByClassName(“flag-container”);
for (var i = 0;i<elems.length;i++) {
var uncheck= elems[i].parentNode.lastElementChild;
const div1 = document.getElementById(uncheck.id);
const exampleAttr= div1.getAttribute(‘class’);
if(exampleAttr == ‘mstrmojo-Label tristate checked’) {
uncheck.click();}
}
}
}
</script>
<body>
<input id=”selectAll” type=”checkbox” onClick=”toggle(this)” /> Read All<br/>
</body>

 

When you run the document you should see the “Read All” new checkbox:
When you click on the “Read All” checkbox, the script looks for all unchecked checkboxes and marks them as checked:


When you uncheck the “Read All” button, all the entries will get unclicked:


This simple javascript can be obviously tailored into your needs and adjusted if