I have a SAPUI5 SelectDialog control, which contains StandardListItem control inside it to display a list of data, something like this:
I can select each entry one by one.
What I want to achieve, is to provide "SELECT ALL" or "DESELECT ALL" functionality. If I press ctrl+A inside dialog box, it works well & selects all the entries inside the dialog. What I want is to provide a button/checkbox at the top, which user can select to select/deselect all the entries at once. Unlike multicombobox, SelectDialog control does not have inbuilt "Select All" method.
Using tutorial at https://www.w3schools.com/jsref/event_ctrlkey.asp, I tried triggering ctrl+A event using a button, but it seems not working. Any input on this?
Code I tried
<script>event.$(document).ready(function(){
$("#myButton").click(function () {
var triggerEvent = $.Event();
triggerEvent.buttonevent == 65; //keycode for alphabet A
triggerEvent.ctrlKey == true;
$(this).trigger('triggerEvent');
});
});</script>
<SelectDialog id="myDialog" growingThreshold="2000"
multiSelect="true" noDataText="NoDataFound" liveChange="handleSearchSelectionDialog" items="{model>/data}"
search="handleSearchSelectionDialog" title="Choose" contentHeight="50%">
<StandardListItem id="abc"
title="SELECT ALL" type="Active"/>
<StandardListItem id="myId"
title="data" type="Active"/>
<button onclick="clicked" id="myButton">SELECT ALL</button>
</SelectDialog>
Thanks.
See Question&Answers more detail:os