When you have an enumeration field, it would be handy to have a configurable text in there when it's empty. Something like: "please select"
Hi Eric Tieniber,
I'm trying to apply this approach with Mendix 9.18.4.
I'm having trouble putting this into practice.The error message I'm seeing is, "Error while evaluating javascript input: Cannot read properties of undefined (reading 'previousSibling') due to a type error.
Please let me know what might be the problem.
Hi Eric Tieniber,
I am trying to implement this solution in Mendix 6.2.1.
I am facing issues while implementing this.
I am getting an error message as ''Error while evaluating javascript input: TypeError: Unable to get property 'getAttribute' of undefined or null reference".
Please let me know, what might be the issue.
Thanks in advance
Eric - I am trying to upgrade my current application from 6.9.0 to 7.6.0 modeler version and I have used the earlier script which you provided to remove the blank Options in drop down for 6.9.0 and it works.
Issue: Now when i am using the below code which is provided to remove blank options,
var selector;
selector = dijit.registry.byNode(this.domNode.previousSibling);
if (typeof selector === "undefined") {
selector = dijit.registry.byNode(this.domNode.previousSibling.children[1]);
}
define(["dojo/aspect"], function(aspect){
aspect.after(selector, "_renderOptions", function(deferred){
this._editNode.removeChild(this._editNode.children[0]);
return deferred;
});
});
I observed that the code from "define" is not executing and it is because the functions is not identified.
Please suggest the changes which i can incorporate to make this work.
Kudos for sharing, Eric!
Updated sample code for Mendix 7:
var selector;
selector = dijit.registry.byNode(this.domNode.previousSibling);
if (typeof selector === "undefined") {
selector = dijit.registry.byNode(this.domNode.previousSibling.children[1]);
}
define(["dojo/aspect"], function(aspect){
aspect.after(selector, "_renderOptions", function(deferred){
this._editNode.removeChild(this._editNode.children[0]);
return deferred;
});
});
Temporary solutions below. Add an HTMLSnippet snippet widget after your reference selector.
To remove the blank option (tested and cross-browser compatible):
var selector;
selector = dijit.registry.byNode(this.domNode.previousSibling);
if (typeof selector === "undefined") {
selector = dijit.registry.byNode(this.domNode.previousSibling.children[1]);
}
dojo.require("dojo.aspect");
dojo.aspect.after(selector, "_renderOptions", function(deferred){
this._editNode.removeChild(this._editNode.children[0]);
return deferred;
});
To set the blank option's text (untested - if syntax is correct it should work):
var selector;
selector = dijit.registry.byNode(this.domNode.previousSibling);
if (typeof selector === "undefined") {
selector = dijit.registry.byNode(this.domNode.previousSibling.children[1]);
}
dojo.require("dojo.aspect");
dojo.aspect.after(selector, "_renderOptions", function(deferred){
this._editNode.children[0].innerHTML = "<Please enter a value>";
return deferred;
});
When I set the default value to enumration, as a user, I must have the ability to Include/exclude blank values from the dropdown list.
I also requested this one but on the dropdown widget itself because sometimes the placeholder text can be different per page.
please see https://forum.mendix.com/link/ideas/22