custom: function (ui, fieldOptions) { var scoreValidator = $("#grid").igGridUpdating("editorForKey", "FirstName").data("igValidator").element; var gradeValidator = $("#grid").igGridUpdating("editorForKey", "Grade").data("igValidator").element; if(ui>0){ $(gradeValidator).igValidator("option", "required", true); $(gradeValidator).igValidator("option", "errorMessage", 'Enter Grade too!'); return true; } return true;
}
can anyone explain what's the meaning of returning true?what will happen if we return false .Please provide a brief and simple explanation if .
Hello,
I have been looking into your question and the required error message as follows and from its name is displayed only when the field is not filled in the cell does not have any value and must be filled, then the required error message is displayed to notify the user that this field is required and must be filled with some value.
When the user enters a value that does not meet your requirements and you return false to indicate the cell as invalid, the message displayed in the igValidator notification is „This field needs attention“, and this message is the default message in this situation.
To provide a custom message in the igValidator's notifications that gives more information to the user you can take the cell editor's validator.
var validator = $("#grid").igGridUpdating("editorForKey", "LastName").data("igValidator").element;
Then change the error message by handling the validator's errorMessage option and provide your own message.
$(validator).igValidator("option", "errorMessage", 'Please enter ui > 0!');
The described scenario could be observed here:
In addition, I have prepared small sample illustrating this behavior which could be found here. Please test it on your side and let me know how it behaves.
If you require any further assistance on the matter, please let me know.
Regards,
Georgi Anastasov
Entry Level Software Developer
Infragistics
So, when ui<0 it will display any random error message or it will display the message provided in the required field?
I have been looking into your question and yes, if your requirement is ui > 0 and the user enters a value greater than 0 then the user meets your requirements, and the cell field is valid therefore you will return true so that the cell can be identified as valid, and the row editing can continue by the user.
In the other case if the user enters a value less than 0 then the user does not meet your requirements and the cell field will not be valid therefore you will return false to indicate that the cell is invalid and prompt the user to enter a new value greater than 0.
Thanks for your reponse.Just alil more doubt. In my code, if ui>0 then i m returning true that means for any value greater than 0 for that field user can submit and i should replace the return true outside if to return false then user will not be able to complete editing if ui <0 . Am i right?
I have been looking into your question and custom is an option that gets or sets a custom function to perform validation of the currently edited cell from the handle column to which validation has been added.
When you edit the cell with the custom function, you can take the entered value for the edited cell from the column on which you applied validation and handled the custom option. With this value you can perform additional custom validation as in your case if the value is defined if it is greater or less than some target. Then if the entered value in the cell meets your requirements you return true for the function itself to indicate that the value is according to the validation and the edited cell is valid. If the value does not meet your requirements, you return false for the custom function and then the edited cell will not be valid, and the editing will not be completed as the user will have to enter a valid value for the edited cell.
In summary, true is returned when the entered value meets your validation requirements and then the cell is valid, and false is returned when the value does not meet your requirements and the cell becomes invalid and editing cannot be completed.
In addition, I have prepared a small sample illustrating this behavior which could be found here. Please test it on your side and let me know how it behaves.