Validation call not triggered on grid column sort / filter

4 posts, 1 answers
  1. SANJEEV
    SANJEEV avatar
    2 posts
    Member since:
    Mar 2013

    Posted 03 Jun 2013 Link to this post


    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.}
  2. Answer
    Daniel
    Admin
    Daniel avatar
    2117 posts

    Posted 05 Jun 2013 Link to this post

    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!
  3. Kendo UI is VS 2017 Ready
  4. SANJEEV
    SANJEEV avatar
    2 posts
    Member since:
    Mar 2013

    Posted 05 Jun 2013 Link to this post

    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?
  5. Daniel
    Admin
    Daniel avatar
    2117 posts

    Posted 07 Jun 2013 Link to this post

    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!
Back to Top
Kendo UI is VS 2017 Ready