jQWidgets Forums
jQuery UI Widgets › Forums › Grid › validateeverpresentrowwidgetvalue execute twice?
This topic contains 9 replies, has 4 voices, and was last updated by SandBird 5 years, 6 months ago.
-
Author
-
Please refer to this example: http://jsfiddle.net/vkLvyn69/4/
Just modified your demo: demos/jqxgrid/everpresentrowvalidation.htm
From:
return { message: “Entered value should be more than 5 characters”, result: false };
To:
alert(“error”);
return false;And I’ll get the alert twice (validateeverpresentrowwidgetvalue triggered twice)
By the way, what is => return { message: “Entered value should be more than 5 characters”, result: false }; ? Looks like return this object doesn’t do anything?
Hi KK,
It is called as many times as it is necessary for validation of All editors in the row. It could be called more than once of course.
Best Regards,
Peter StoevjQWidgets Team
http://www.jqwidgets.comI’m talking about the validation on the same ‘Name’ column will be executed more than once, not a general validation for all editors in the row.
Error alert for invalid data entered in ‘Name’ column will be shown multiple times when you try to add a row of data.Hi KK,
And the answer is the same.
Best Regards,
Peter StoevjQWidgets Team
http://www.jqwidgets.comHi Peter,
May I ask why the validation function is called twice? According to your reply, it is to validate all editors in the row, does it mean there are 2 editors in the row? but there are 4 columns, all editable.
Sorry to bring this old post up, but it is eating me up, I just can’t figure it out.
Thank you
Hi suall936,
The function is called when necessary It does not matter how many times its called, just add your validation logic in it if your intentions are to use it. Otherwise, you can add own custom validation logic and do not use our validation functions.
Best Regards,
Peter StoevjQWidgets Team
http://www.jqwidgets.comHi Peter,
Thank you.
Is it possible to access the error message raised in the validation function?
return {message: “Entered value should be more than 5 characters”, result: false };
Hi suall936,
Why should you access it? You can change it by returning a different message depending on the column.
Best Regards,
Peter StoevjQWidgets Team
http://www.jqwidgets.comHi Peter,
Reason is the error message displays as tooltip (correct me if I’m wrong), if I can access the message I can put it in a warning panel or something similar.
Regards.
Hello Peter,
I apologize to revive this yet again but since I also encountered the same issue I wanted to ask about it.
Following the examples on the site (and then some), I have the following validation check (simplified version):
validateEverPresentRowWidgetValue: function (datafield, value) { switch (datafield) { case "name": if (value.length == 0) { message = "Name field must be bigger than 0 characters"; } else if (value.length > 45) { message = "Name field must be smaller than 45 characters"; } else if (value.replace(/\s/g, "") === "") { message = "Please enter a valid input"; } else { $.ajax({ ...some ajax code where variable uniqueValData is assigned an appropriate value if entered value is unique. }); if (uniqueValData !== 0) { message = "This value already exists, please enter a unique value"; } else { return true; } } notification("error", message, "#dataGrid"); //built-in function to utilize jqxNotification return { message: message, result: false }; break; } return true; }
The problem, as the previous users noted, is that this it runs twice on the same editor. In the case above the function will iterate twice for the “name” editor – I know this because I get two notification prompts.
Shouldn’t the function run only once? or at least per theswitch (datafield)
it should only validate once for the “name” editor. Otherwise I see it goes twice also to the database to check (I see two same consecutive ajax calls) which I don’t see a reason to.You mentioned (in post #74421) that ” Otherwise, you can add own custom validation logic and do not use our validation functions.” I am unsure if you are referring to something else than the above and if so I would appreciate if you can please share or point to where I can see how to do that.
Thank you for your time clearing the confusion about this.
-
AuthorPosts
You must be logged in to reply to this topic.