Issues in validation for grid columns

Hi,

I am having some issues in performing validations on grid columns-

1. The built in validations are not working

2. By default, only the first editable field from left has required field validation with message as 'At least one field must be updated'. How can I change the message?

3. I am trying to put a custom validator.
    In <head> section of cshtml page i have written this script-
    <script src="../../Scripts/jquery-1.10.2.js"></script>
    <script src="../../Scripts/jquery.validate.js"></script>
    <script src="../../Scripts/jquery.validate.unobtrusive.js"></script>
    <script type="text/javascript">
        $(function () {
            console.log($);
            console.log($.validator);
            $.validator.addMethod("customValidatorRequiredField", function (value, element, params) {
                return !(element.value == '' || element.value == null || element.value == undefined);
            }, "Required Field");
        });
    </script>

But I am getting error in console as "Cannot read property 'addMethod' of undefined"

The outputs of console.logs are as follows-
console.log($); -                ƒ ( selector, context ) {
                          // The jQuery object is actually just the init constructor 'enhanced'
                              return new jQuery.fn.init( selector, context, rootjQuery );
                                   }
console.log($.validator); -  undefined

I guess its unable to find 'validator'. I have included required script files in the page-
jquery-1.10.2.js, 
jquery.validate.js, 
jquery.validate.unobtrusive.js


Could you please help me with the above issues? I have attached the .cshtml file for your reference.


Regards,
Kaushik


Attachment: Admin_acca0621.7z

1 Reply

KM Kuralarasan Muthusamy Syncfusion Team April 19, 2018 09:53 AM UTC

Hi Kaushik, 

Thanks for contacting Syncfusion support. 

Query #1: The built in validations are not working 
 
We are not able to reproduce this issue. So we have prepared the sample with your requirement and we have attached that sample in this update. 

Query #2:  By default, only the first editable field from left has required field validation with message as 'At least one field must be updated'. How can I change the message? 
 
From your query we found that you want to change the default validation message. So we suggest you to Grid localization to edit this validation message. 
 
Please refer the following code example: 
 
@(Html.EJ().Grid<EmployeeView>("Grid") 
      
               ...... 
 
) 
<script> 
    ej.Grid.Locale["en-US"] = { 
        EmptyRowValidationMessage: "Enter the validation message here..." 
    }; 
</script> 

Please refer the following link to know about Grid localization: 


Query #3: But I am getting error in console as "Cannot read property 'addMethod' of undefined" 
We have analyzed this query and we suspect that jquery is multiple times referred in your sample. We can reproduce this issue in this case only. So please ensure the jquery reference. If it referred in multiple times then please remove any one of them. 
 
 
Still if you face same issue, please share the following details, 
 
  1. If you face any issue in console window then share the screenshot of the issue.
  2. Share the Essential studio version.
  3. If possible replicate the issue in the above sample and send us back.


Regards, 
Kuralarasan M. 


Loader.
Up arrow icon