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

How can I get access to the grid model?

1 Answer 742 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Randy
Top achievements
Rank 1
Randy asked on 14 Apr 2017, 05:28 PM

When you attach a function to the grid edit event, the parameter passed to the function contains the grid model as follows:

function onEdit(e) {
    if (e.model.isNew()) {

   ...
    }
}

I have a function in my page that sets the blur event for each cell in a row being edited. It looks as follows:

function setUpOnBlurEvent() {
    $("body").on("blur", "table tr.k-grid-edit-row input", function () {
        ...
    });
}

In the function definition above for the blur event, I need to get access to the grid model so that I can enter values in certain cells of the row being edited. How can I get access to this model. Or, is there an alternate way of inserting values into other cells in the grid row being edited from my blur event function?

 

1 Answer, 1 is accepted

Sort by
0
Preslav
Telerik team
answered on 18 Apr 2017, 01:07 PM
Hi Randy,

Based on the provided information, I believe that the best approach might be handling the blur event in the edit function. For example:

function onEdit(e) {
    var model = e.model;
 
    $("table tr.k-grid-edit-row input").on("blur", function() {
        console.log(model);
    });
};

Please, notice how I am saving the row model in a temporary variable.

I hope this helps.


Regards,
Preslav
Telerik by Progress
Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
Tags
Grid
Asked by
Randy
Top achievements
Rank 1
Answers by
Preslav
Telerik team
Share this question
or