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

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

1 Answer 81 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Duncan Clarke
Top achievements
Rank 1
Duncan Clarke asked on 30 Apr 2015, 07:28 AM

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?

1 Answer, 1 is accepted

Sort by
0
Vladimir Iliev
Telerik team
answered on 04 May 2015, 07:46 AM
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.

 
Tags
General Discussions
Asked by
Duncan Clarke
Top achievements
Rank 1
Answers by
Vladimir Iliev
Telerik team
Share this question
or