Null error on Update Function

2 posts, 0 answers
  1. Allan
    Allan avatar
    34 posts
    Member since:
    Aug 2015

    Posted 31 May 2016 Link to this post


    I have written a function that triggers when the Update event on the grid ends.  This is defined as :

    .DataSource(dataSource => dataSource
                   .Events(events =>
                   .Model(model =>
                       model.Id(p => p.vessel_idx);                   

    My function is as follows:

    function onUpdateEnd(e) {
           if (e.type == "update") {
               var grid = $("#Grid").data("kendoGrid"),
                   dataItem = grid.dataItem($(this).closest("tr")),
                   stop_date = document.getElementById("fixture_stop"),
                   start_date = dataItem.fixture_start;
               if (end_date < start_date) {
                   alert("Dates are wrong")
               } else {
                   alert("Dates are correct")

    The problen that once the updateend function trigger, the console returns an error saying that dataItem is null (start_date) which crashes the application.  What am I doing wrong and why can't I grab that cell data for use in my function?

    Many thanks


  2. Konstantin Dikov
    Konstantin Dikov avatar
    2466 posts

    Posted 02 Jun 2016 Link to this post

    Hello Allan,

    Thank you for contacting us.

    Could you please elaborate what you are trying to achieve, so we can suggest you the best approach for it? In the provided code snippet, the issue that you are facing is due to the fact that "this" will be the DataSource object and no TR element will be found with .closest("tr"). If you need to get reference to the record from the DataSOurce you could use the event arguments:

    If any further assistance is needed, please provide additional information on the exact requirement that you have.

    I am looking forward to your reply.

    Konstantin Dikov
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Back to Top