This is a migrated thread and some comments may be shown as answers.

[Solved] custom grid validation with $http.get

2 Answers 145 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Wit
Top achievements
Rank 1
Wit asked on 24 Sep 2014, 10:40 AM
My validation rule has to make a call to server. I have tried to add $http.get as part of myRule function but is not working.

Please see example code:
http://dojo.telerik.com/aJeXE/2

Thank you

2 Answers, 1 is accepted

Sort by
0
Accepted
Alexander Popov
Telerik team
answered on 26 Sep 2014, 07:18 AM
Hello Wit,

I would recommend using a synchronous request to ensure that the response is received before the validation function has finished executing. For example: 
function (input){
    var valid = true;
    if (input.is("[name='ProductName']") && input.val() != "") {
        $.ajax({
            type: "GET",
            url: "someurl",
            async: false
        })
         .success(function(data){
            if(!data.someCondition){
                valid = false;
            }
        });
    }
    return valid;
}


Regards,
Alexander Popov
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
0
Wit
Top achievements
Rank 1
answered on 26 Sep 2014, 10:57 AM
Thank you
Tags
Grid
Asked by
Wit
Top achievements
Rank 1
Answers by
Alexander Popov
Telerik team
Wit
Top achievements
Rank 1
Share this question
or