ServiceDesk Forms use the EnsembleMenuSelect Component to represent Hierarchy Data, for example: This example shows a manageable list; If your data is less than manageable, you can use the following technique to "bubble" list items to the top. We will be using an 'onkeydown' event in the EnsembleMenuSelect Component which compares the pressed key against the 1st character of each list item. The component configuration looks like this: The charBubble() function resides in the Form Builder -> Behavior -> Script configuration, for example: JavaScript source:
function charBubble() { if (document.querySelector('a.top_level_over')) { var categories = document.querySelector('div.dropmenudiv'); this.onkeypress = function(e) { e = e || window.event; var charCode = (typeof e.which == "number") ? e.which : e.keyCode; if (charCode > 0) { var dropList = categories.getElementsByTagName("a"); var l = dropList.length; for (i = 0; i < l; i++) { if (dropList[i].text.charAt(0).toLowerCase() == String.fromCharCode(charCode).toLowerCase()) { categories.insertBefore(dropList[i], dropList[0]); } } } }; } }
The following behavior can be expected:
NOTE: The attached project utilizes the ServiceDesk Incident Management Hierarchy.