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

How do I set a specific hidden column to a new value from my custom editor?

1 Answer 300 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Pat
Top achievements
Rank 1
Pat asked on 09 Jan 2013, 06:27 PM
I have a custom editor for looking up objects.  Instead of a dropdown, I show a search icon that opens a modal window.  The user then searches for a record in that modal window and clicks a row.  My modal lookup window then closes, and I am now in a javascript function in my custom editor with the selected object from the modal lookup window.

But now, how do I get the selected row from the grid and update the new values into it?  For example, the user picked an object, but now I need to set the Id (hidden) and Name (visible) into the grid.

1 Answer, 1 is accepted

Sort by
0
Alexander Valchev
Telerik team
answered on 11 Jan 2013, 10:13 AM
Hi Pat,

You can get the selected row via the select method of the Grid. In case your grid is not selectable you have to find the closest <tr> element to the clicked button - this approach is demonstrated here. Please note the showDetails function.
function showDetails(e) {
    e.preventDefault();
 
    var dataItem = this.dataItem($(e.currentTarget).closest("tr"));
    wnd.content(detailsTemplate(dataItem));
    wnd.center().open();
}

The dataItem method is used to retrieve the underlying dataSource item. Once you have a reference to the dataItem you may use the set method to update field values. In this way the grid will be notified for the changes in the data and will refresh automatically to display them. Set method can be used for both hidden and visible fields.

Kind regards,
Alexander Valchev
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
Tags
Grid
Asked by
Pat
Top achievements
Rank 1
Answers by
Alexander Valchev
Telerik team
Share this question
or