Search code examples
teleriktelerik-grid

Getting a reference to the text box elements on an edit


In my MVC grid, I'm trapping the Edit event as follows:

 .Events(events => events.Change("gridRowChange").Edit("onEdit"))

In my onEdit() method that gets called when an edit is occurring, I'd like to get a reference to the text box elements for each editable cell in the row so that I can attach an onBlur event to some of them. How do I go about getting a reference to each text box element in the row being edited?


Solution

  • As per Telerik's documentation for OnEdit:

    The event argument exposes three fields: dataItem - the JavaScript object to which the editor row is bound to. It is undefined during insertion. mode - a string whose value is either "insert" or "edit" form - the DOM element which contains all editing components (textboxes, checkboxes, dropdownlists etc.)

    This should get you a reference to a given textbox:

    function onEdit(e) {
        var yourTextBox = $(form).find("#your_id");
    
        yourTextBox.on("blur", function () {
            //your on blur code here
        });
    }