How can I get access to the grid model?

2 posts, 0 answers
  1. Randy
    Randy avatar
    75 posts
    Member since:
    Jul 2009

    Posted 14 Apr 2017 Link to this post

    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?

     

  2. Preslav
    Admin
    Preslav avatar
    574 posts

    Posted 18 Apr 2017 Link to this post

    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.
Back to Top