[Dojo-interest] How to suppress validation on render of dijit/form/Select

mello151 woodgettm at gmail.com
Thu Jan 23 17:08:13 EST 2014


I have a dgrid where I'm using a dijit/form/Select as one of the editors. I'm
trying either:
1. Have a dropdown with a blank default value.
or
2. Have a dropdown that defaults to the first option of list (from a store).

I'm having issues with either approach though:

1. With option 1 of having the blank default value, the validation always
fires and shows invalid on startup. I'd like it to only show error when
blank value is selected by user or when I manually call validation. I'm
assuming this is because the startup() function calls _refreshState() which
triggers validation. Not sure how to get around this though. Since I don't
care whether or not the widget has been blurred I've had to remove this
logic from the validate() function:

                validate: function(/*Boolean*/ isFocused){
                        // summary:
                        //                Called by oninit, onblur, and
onkeypress, and whenever required/disabled state changes
                        // description:
                        //                Show missing or invalid messages
if appropriate, and highlight textbox field.
                        //                Used when a select is initially
set to no value and the user is required to
                        //                set the value.

                        var isValid = this.disabled ||
this.isValid(isFocused);
 //                       this._set("state", isValid ? "" :
(this._hasBeenBlurred ? "Error" : "Incomplete"));
                         this._set('state', isValid ? '' : 'Error');
                        this.focusNode.setAttribute("aria-invalid", isValid
? "false" : "true");
                        var message = isValid ? "" : this._missingMsg;
                        if(message && this.focused && this._hasBeenBlurred){
                                Tooltip.show(message, this.domNode,
this.tooltipPosition, !this.isLeftToRight());
                        }else{
                                Tooltip.hide(this.domNode);
                        }
                        this._set("message", message);
                        return isValid;
                },

2. With option 2, the issue is that the grid's dirty isn't updated with the
selected value. When the grid row is 'submitted', the value for the dropdown
isn't present unless the user had made a change (firing the dgrid-datachange
event)


Also, is there a way I can use mouse.enter/mouse.leave instead of
this.focused?



--
View this message in context: http://dojo-toolkit.33424.n3.nabble.com/How-to-suppress-validation-on-render-of-dijit-form-Select-tp4000825.html
Sent from the Dojo Toolkit mailing list archive at Nabble.com.


More information about the Dojo-interest mailing list