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

Validation call not triggered on grid column sort / filter

3 Answers 180 Views
Validation
This is a migrated thread and some comments may be shown as answers.
SANJEEV
Top achievements
Rank 1
SANJEEV asked on 03 Jun 2013, 07:40 PM

Validation used for a field in KendoGrid works fine on currently being edited cell when I try to select other cell.But It doesn't work when I try to sort any column or use filter. Is it possible to prohibit user from sorting or filtering till validation for the field passes.

Code used for validation in datasource for one of field.
01.Project:{
02.editable:true,
03.validation: {
04.custom: function(input) {
05.if(input.val()=="") {
06.input.attr("data-custom-msg", "Message");
07.return false;
08.}
09.else
10.return true;
11.}
12.}
13.}

3 Answers, 1 is accepted

Sort by
0
Accepted
Daniel
Telerik team
answered on 05 Jun 2013, 02:05 PM
Hello,

Generally speaking, preventing the binding when there are validation errors is not supported, but can be achieved with some additional code. Basically, you should use the dataSource requestStart event to prevent the binding with the event argument preventDefault method when there are errors e.g.

requestStart: function(e){
    var grid = $("#grid").data("kendoGrid");
    if(grid.editable && !grid.editable.validatable.validate()){
        e.preventDefault();
    }
}
Regards,
Daniel
Telerik
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
SANJEEV
Top achievements
Rank 1
answered on 05 Jun 2013, 06:44 PM
Thanks Daniel. It works.    This may be a different question but related to  validation.     It seems on escape key  press, currently field being edited goes out of editable mode and  validation  won't work in this case. How can we disable escape key functionality  in this case?
0
Daniel
Telerik team
answered on 07 Jun 2013, 01:47 PM
Hell again,

The escape key cancels the changes and so the validation is not triggered. I am afraid that there is not a way to disable the escape key without disabling the navigation because the Grid handler will always be bound first.

Regards,
Daniel
Telerik
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
Tags
Validation
Asked by
SANJEEV
Top achievements
Rank 1
Answers by
Daniel
Telerik team
SANJEEV
Top achievements
Rank 1
Share this question
or