How do I edit a Kendo Grid DataSource Object using JQuery?

2 posts, 0 answers
  1. Duncan Clarke
    Duncan Clarke avatar
    6 posts
    Member since:
    May 2009

    Posted 30 Apr 2015 Link to this post

    I have in my View the following:

     

    columns.Bound(o => o.line.ApprovalBy.UserDisplayName)
    columns.Bound(o => o.line.ItemNumber)

     

    Using JQuery,I am able to edit the Item Number line with the following:

     

    ('#grid').data('kendoGrid').dataSource.at(0).line.ItemNumber = 155

     

    However, when I try to edit Approval By which is by default set to null with the following:

     

    ('#grid').data('kendoGrid').dataSource.at(0).line.ApprovalBy = {UserID: 50}

     

     It returns an "undefined" in the grid for some reason.

    When I try to edit an object that has been initialized previously, it would be able to work:

     

    columns.Bound(o => o.line.Vehicle.Color);

    ('#grid').data('kendoGrid').dataSource.at(0).line.Vehicle.Color = "red";

     

    What am I missing?

  2. Vladimir Iliev
    Admin
    Vladimir Iliev avatar
    2172 posts

    Posted 04 May 2015 Link to this post

    Hi Duncan,

    Current behavior is expected when trying to set nested fields of field which is null - in current case I would suggest to either set default value for the "line" field or manually set it's value before trying to set the child field value. 

    Regards,
    Vladimir Iliev
    Telerik
     

    See What's Next in App Development. Register for TelerikNEXT.

     
  3. UI for ASP.NET MVC is VS 2017 Ready
Back to Top