PDA

View Full Version : [CLOSED] Turn RemoteValidation on/off



bogc
Mar 05, 2013, 10:33 PM
Hello:

I have a form with a bunch of fields that have remote validation that gets fired when the change event is fired. Is it possible to turn the remote validation off for all the controls on the form that have it, before loading the values in the form (the values that come from the db don't need validation), and then turn it back on?


Thanks

Baidaly
Mar 06, 2013, 12:36 AM
Hello!

It seems that the easiest way to do this is to disable form and enable it again.

http://docs.sencha.com/ext-js/4-1/#!/api/Ext.container.AbstractContainer-method-disable
http://docs.sencha.com/ext-js/4-1/#!/api/Ext.AbstractComponent-event-enable

bogc
Mar 06, 2013, 12:39 AM
I created the following function and I call it after I load the values to cancel any remote validation tasks


cancelRemoteValidationTasks: function(container)
{
var me = this;
container.items.each(function(control){
if (control.isRemoteValidation && control.rvTask)
control.rvTask.cancel();

if (control.items && control.items.length > 0)
me.cancelRemoteValidationTasks(control);
});

},

Baidaly
Mar 06, 2013, 1:06 AM
Thank you for sharing! Yes, this is good solution!

However, we have deactivateRemoteValidation and activateRemoteValidation methods for BasicField, but for some reasons activateRemoteValidation throws exception. We are investigating.

Daniil
Mar 06, 2013, 5:27 AM
Hello,


but for some reasons activateRemoteValidation throws exception. We are investigating.

It has been fixed in SVN trunk.

Please note that if a field's IsRemoveValidation="true" then its activateRemoteValidation is called automatically.

I would avoid it.

1. Set up IsRemoveValidation="false" or just remove this property, because false is by default.
2. Call the activateRemoteValidation method and set up isRemoveValidation to true for each field after loading data.