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

[Solved] Is there a way to have a custom editor with a dropdownlist and grid

1 Answer 335 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Andrea
Top achievements
Rank 1
Andrea asked on 16 Jan 2015, 09:53 PM
I have a grid where one of my fields is an attribute type with and id and text that needs to be edited with a dropdownlist in the popup editor. When a specific value in that dropdownlist is selected I need to be able to show a grid in the editor as well to set additional values. These values are not part of the original grid. I've tried creating a custom editor template but ran into problems binding the data for the dropdownlist. The attribute type in the original grid kept getting set to undefined, but the correct value was getting back to the database. I tried using the built in editor and just setting the editor for the dropdownlist and adding a grid to the popup editor in the change event, but that wasn't working at all (the grid showed up but with the header at the bottom and covered everything else in the popup). Is there a way to do this and still have all of the values data bound to the original grid?

Thanks,
Andrea

1 Answer, 1 is accepted

Sort by
0
Petur Subev
Telerik team
answered on 21 Jan 2015, 07:35 AM
Hello Andrea,

What exactly is that attribute type that you mentioned you want to edit with a DropDownlist inside the popup editor, could you please share how you have defined the column and dataSuorce.schema.model and the editor template of the Grid. Also how does the object look like on your server side?

Basically we have covered two cases how to edit a related entity. One of them is to change an ID field of the Grid model that points to the PK of another table - a.k.a. ForeignKey. With this approach you need to provide text/value pair collection to the Grid, so it can show the text instead of the ID inside that column, inside the filter menu, and when the Grid is grouped etc. The same collection is used to feed the DropDownList editor for that column. Everything is coming out of the box.
live demo:

http://demos.telerik.com/kendo-ui/grid/foreignkeycolumn

Another approach that we have demonstrated is to update whole nested object part of the Grid model. This way you do not have to provide key/value collection, but filtering, grouping and sorting won't work automatically because the Grid does not know how to compare the nested objects.

http://demos.telerik.com/kendo-ui/grid/editing-custom

Both approaches have their pros and cons and you need to decide which suits your needs better.

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