How do you hide (empty) in Drop-down Search Fields of Data Grids

0
Since the upgrade from Mendix 7.23.19 to Mendix 8.17.1 the enumeration value (empty) appears in every Drop-down Search Field of all Data Grids. Is there a solution to hide the (empty) value?
asked
1 answers
1

Hi Mats,

You can use the following JavaScript code with the HTML Snippet widget. Put this at the bottom of your page. 

mx.addOnLoad(function () {
    var searchDropDownList = document.querySelectorAll('.mx-grid-search-item select');
    for (var i = 0; i < searchDropDownList.length; i++) {
        // Get the ID from the parent parent
        var searchDropDownID = searchDropDownList[i].parentElement.parentElement.id;

        // Search for the option where the value ends on a _, that is the option value for (empty)
        var emptyOption = searchDropDownList[i].querySelector('[value=' + searchDropDownID + '_]');
        if (emptyOption) {
            searchDropDownList[i].removeChild(emptyOption);
        }
    }
})

I’ve set the following options:

  • Refresh on context change: Yes
  • Refresh on context update: Yes
  • Enclose HTML with DIV: No

 

I’ve tested it in Studio Pro 8.12.5.

Cheers,

Jeffrey

answered