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

Binding to custom editor for a grid column (i.e. drop down list)

6 Answers 389 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Paul
Top achievements
Rank 1
Paul asked on 13 Jun 2012, 03:22 PM
How do you specify a custom editor function for in-line editing with ASP.NET MVC?  If I was doing this strictly on the client side I would set the 'editor:' attribute on the column with a javascript function name.  Is there a way to specify an editor function using Razor syntax in my view?

FYI, the scenario here is very simple - I have a list of Products and each product record has a Category ID field.  When I add or edit a product, I want the user to select from a list of defined categories.  The category items can come from server on initial page load or dynamically from ajax (in this case, I really don't care which - the category list doesn't change much).

Thanks in advance.

6 Answers, 1 is accepted

Sort by
0
Yawar
Top achievements
Rank 1
answered on 08 Jul 2012, 03:09 AM
exactly what I am trying to do but I am unable to do it. Did you get any response for this?
0
Paul
Top achievements
Rank 1
answered on 08 Jul 2012, 04:43 PM
Found a hacky sort of work-around buy attaching the custom editor client-side after the grid is created.  I included the following javascript function as part of the <script> tag in the view (after the grid is defined)...

        $(function() { 
            var grid = $("#Grid").data("kendoGrid");
            var col = grid.columns[0];
            col.editor = categoryDropDownEditor; // attach custom editor function to column
        });

Then I created the custom editor function in a stand-along .js file for this page so I could use the VS debugger on it.  I bit of a kludge, but it does work.  I'd still like to see a better server-side solution on this.

-Paul
0
Atlas
Top achievements
Rank 1
answered on 12 Jul 2013, 05:20 PM
I thought the kendo forums were supposed to be premium forums?
Hey Telerik, can you respond to this issue?
0
Daniel
Telerik team
answered on 17 Jul 2013, 12:29 PM
Hello,

The MVC Grid uses the MVC EditorTemplates and currently does not support setting a JavaScript function. If you believe that this functionality should be added then I can suggest to create a feature request in our user voice forum so we can track its interest.

Regards,
Daniel
Telerik
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
loi
Top achievements
Rank 1
answered on 20 Sep 2013, 08:23 PM
I needed to do something similar, and setting the column editor javascript name is still not supported right now. Added a request for this feature.
http://feedback.kendoui.com/forums/127393-kendo-ui-feedback/suggestions/4459400-setting-the-mvc-grid-column-editor-javascript-func
0
Curt Rabon
Top achievements
Rank 1
Veteran
answered on 19 Mar 2015, 09:50 PM
One good reason this is need is so you can have standard HTML inputs, elements, etc. in your editor, and not just a single Kendo MVC widget.  I tried putting standard HTML (couple of checkboxes and some span elements) inside a MVC Editor-template, but there's 2 main problems:
(1) when you click anything other than the checkbox (the span element, or other text) the editor is automatically closed.
(2) the grid's "save" event is not fired when the editor is closed (where you could manually update the model).  This can be fixed by having an "apply" button/span that the user clicks inside your editor and you can get the row's data-item model, but clicking around in the editor causes the editor to close.
Tags
Grid
Asked by
Paul
Top achievements
Rank 1
Answers by
Yawar
Top achievements
Rank 1
Paul
Top achievements
Rank 1
Atlas
Top achievements
Rank 1
Daniel
Telerik team
loi
Top achievements
Rank 1
Curt Rabon
Top achievements
Rank 1
Veteran
Share this question
or