- Use a Kendo UI Grid
- Have columns that have dropdowns for editors
- Have a re-usable method to implement those dropdowns
- Send the values from the grid to the server when the form posts
Here's what I've done so far:
I have the grid showing on my page and editable. I am able to send the values from the grid to the server with the form post (using a method similar to the one shown here: http://www.telerik.com/support/code-library/submit-form-containing-grid-along-with-other-input-elements)
I have looked at the custom editor examples here (http://demos.telerik.com/kendo-ui/web/grid/editing-custom.html) and here (http://docs.telerik.com/kendo-ui/getting-started/using-kendo-with/aspnet-mvc/helpers/grid/editor-templates) but this method involves creating a partial view for each dropdown. I would prefer not to have to copy/paste/edit this code every time I need a new dropdown. I think there should be a way to create a re-usable partial view that can perform this function. Along these lines, I have created a small view model and partial view like what is mentioned here (https://stackoverflow.com/questions/11498215/asp-net-mvc-built-in-support-for-dropdownlist-editor-template).
The dropdown appears in my grid as expected, and I can select a value. I don't know how to get the text and value of the selected item so I can include them in the ClientTemplate, however.
The small viewmodel for my dropdown partial editor looks like this:
My partial view looks for the dropdown editor looks like this:
So my question is: is there a way to fix my ClientTemplate for the FormsViewModel column so that it displays the text of the selected item when not being edited (instead of 'text' as it does now) and submits the ID of the selected item to the server? Alternatively, is there another way to do this that meets items 1-4 at the top of this post?
Any ideas are appreciated.