I have created a custom widget with configuration in web appbuilder. What I need to do is disable "Ok" button or do nothing if all fields in the config screen are not filled. In other words, I need to do save only when all inputs are filled. Any idea how to achieve it?
Regards,
Jamil
Solved! Go to Solution.
Jamil,
OK Sorry, they do not provide access to disable the main widget settings button like that. You can use the code I provided for an subsequent/additional popups.
Jamil,
Simple as
this.popup.disableButton(0);
Where to write that? I write on Settings.js postCreate method, but there is no "this.popup".
I am doing like this
return declare([BaseWidget], {
baseClass: 'jimu-widget-MyWidget-setting',
postCreate: function () {
this.inherited(arguments);
this.popup.disableButton(0);
},
});
Regards,
Jamil
Jamil,
OK Sorry, they do not provide access to disable the main widget settings button like that. You can use the code I provided for an subsequent/additional popups.
I'll provide my solution, even though this is an old post, since it's a top Google result.
As far as I know, you cannot disable the OK button, but there is a way to prevent users from moving forward if they don't meet your validation test.
When you click OK on the widget settings page, the getConfig() method is fired. If we return false on this method, the user will not be able to close the settings page. Therefore, we can add a validation method and return false if some criteria is not met - with a popup indicating what the user omitted.
getConfig: function() {
if ( !this.yourValidationMethod ) {
return false
}
},
yourValidationMethod: function() {
if (lang.trim(this.someInput.get('value')) === '') {
return false;
} else {
return true
}
}