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

Trigger validation of a different column

2 Answers 465 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Jamie
Top achievements
Rank 1
Jamie asked on 03 Jan 2013, 03:11 PM
Greetings,  I'm using editable grid and I want to trigger validation of a note column after the user enters a valid key code in another column.  Any suggestions on how to call validate on another column?

I created this to help: http://jsfiddle.net/Tevyn/jxkPw/


2 Answers, 1 is accepted

Sort by
0
Jon
Top achievements
Rank 1
answered on 04 Jan 2013, 03:12 PM

You can either perform the validation yourself manually or cause the validation cell to be edited.

When the onSave function is fired, check to see if it is a matching keycode that has been modified. If so, close the cell and force the edit of the notes cell. If it is in violation, it will show the warning.

function onSave(e) {
   if (e.values.KeyCode == "B") {
     var grid = $("#grid").data("kendoGrid");
     grid.closeCell();
     grid.editCell(e.container.siblings("td:nth-child(4)"));
   }
}

I updated your JSFiddle here .

0
Alexander Valchev
Telerik team
answered on 04 Jan 2013, 03:17 PM
Hi Jamie,

Thank you for providing an example.

I see that you already implemented custom validation rule for Notes column and it seems to be working well. As I understand the question is how to trigger the edit mode of Notes cell when user enter "B" KeyCode. To achieve that you can use closeCell and editCell methods.
function onSave(e) {
    if(e.values.KeyCode === "B") { //if the entered KeyCode is B
        var noteCell = e.container.closest("tr").find("td:last"); //select the notes cell
        this.closeCell(); //close the current cell
        this.editCell(noteCell); //trigger the edit mode of notes cell
    }
}

Here is a link to the updated fiddle: http://jsfiddle.net/valchev/jxkPw/8/

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