Dec 03, 2012, 12:59 PM
[CLOSED] RemoteValidation error remains after changing via directevent
Hi,
I'm a little bit stuck :
I have a textfield with remotevalidation :
When I change the fields value by typing a wrong text, the error shows, what's the expected behaviour.
Then I open a window with values, and by doubleclick I execute the following :
is invalid. If I manually go inside the field, the blur event is called and the field is validated and the error
is gone. But only if I do it manually.
I want the field to be valid.
That's the method, that does the validation :
Regards,
Holger
I'm a little bit stuck :
I have a textfield with remotevalidation :
Html.X().TextFieldFor(m => m.ES_TRANS_KK)
.ID("txt_ES_TRANS_KK")
.Width(150)
.FieldLabel("Krankenkassennr.")
.LabelAlign(LabelAlign.Top)
.Listeners(li => { li.Change.Handler = "setVersicherter();"; })
.IsRemoteValidation(true)
.MsgTarget(MessageTarget.Qtip)
.ValidateOnChange(true)
.ValidateOnChange(true)
.RemoteValidation(rv =>
{
rv.Url = "/Home/isES_TRANS_KKValid";
rv.Method = Ext.Net.HttpMethod.POST;
rv.EventOwner = ValidationEventOwner.Input;
rv.ValidationEvent = "blur";
rv.Delay = 0;
})
.DirectEvents(de =>
{
de.Blur.Url = Url.Action("settxt_KK_NAME_TRANS");
de.Blur.ExtraParams.Add(new Parameter("ES_TRANS_KK", "this.value", ParameterMode.Raw));
})
This works fine.When I change the fields value by typing a wrong text, the error shows, what's the expected behaviour.
Then I open a window with values, and by doubleclick I execute the following :
public ActionResult DirectEventKrankenkasseTransClicked(String KK_ID)
{
try
{
var window_KK_KrankenkasseTrans = this.GetCmp<Window>("window_KK_KrankenkasseTrans");
window_KK_KrankenkasseTrans.Close();
KK_Krankenkasse kasse = db.KK_Krankenkasse.First(m => m.KK_ID == KK_ID);
var txt_KK_NAME_TRANS = this.GetCmp<TextField>("txt_KK_NAME_TRANS");
txt_KK_NAME_TRANS.SetValue(kasse.KK_Name); //<- HERE I SET THE VALUE TO A VALID VALUE
var txt_ES_TRANS_KK = this.GetCmp<TextField>("txt_ES_TRANS_KK");
txt_ES_TRANS_KK.SetValue(kasse.KK_ID);
//txt_ES_TRANS_KK.FireEvent("blur"); <---- THIS DOESN'T WORK
//txt_ES_TRANS_KK.Validate(); <------ THIS DOESN'T WORK
//X.Js.Call("blurAndValidateField", "txt_ES_TRANS_KK"); <------ HERE I TRIED TO DO IT DIRECTLY, DIDN'T WORK
return this.Direct();
}
catch (Exception e)
{
Console.WriteLine("{0} Exception caught.", e);
X.Msg.Alert("Error", e.Message).Show();
return this.Direct();
}
}
After the window closes, the value is displayed correctly, but the validation stays false and the fieldis invalid. If I manually go inside the field, the blur event is called and the field is validated and the error
is gone. But only if I do it manually.
I want the field to be valid.
That's the method, that does the validation :
public JsonResult isES_TRANS_KKValid(string value)
{
JsonResult result = new JsonResult();
bool KK_IDExists = db.KK_Krankenkasse.Any(m => m.KK_ID == value) || String.IsNullOrEmpty(value);
if (KK_IDExists)
{
result = createJSONResultForValidation(value, true, "");
}
else
{
result = createJSONResultForValidation("Kasse existiert nicht !", false,"");
}
return result;
}
private JsonResult createJSONResultForValidation(string value, bool caseValid, string jscript)
{
JsonResult result = new JsonResult();
Object Data = new
{
message = value,
valid = caseValid,
script = jscript
};
result.Data = Data;
return result;
}
When I try to blur the field by code, it doesn't workfunction blurAndValidateField(fieldId) {
blurAndValidateField
var cmp = Ext.getCmp(fieldId);
cmp.fireEvent("blur");
var isValid = cmp.isValid();
if (isDebug) {
console.log("blurAndValidateField : " + isValid);
}
//cmp.clearInvalid();
//cmp.validate();
//cmp.isValid();
//validateForm();
}
How can I get the field to be valid ???Regards,
Holger
Last edited by Daniil; Dec 07, 2012 at 6:46 AM.
Reason: [CLOSED]