Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
515
regarding doubt in a piece of code
posted

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 .

Parents
  • 460
    Offline posted

    Hello,

    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.

    The described scenario could be observed here:

     

    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.

    If you require any further assistance on the matter, please let me know.

    Regards,

    Georgi Anastasov

    Entry Level Software Developer

    Infragistics

Reply Children