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

Dropdown on Grid using inline edit - MVC Wrappers

2 Answers 706 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Ricardo
Top achievements
Rank 1
Ricardo asked on 20 Feb 2013, 06:15 PM
Hi I've been testing the ASP MVC and didnt find a way to use the grid edit inline with a field with dropdown list. is this possible? Even on the samples provided i've adapted the sample "Editing_Custom" to be Inline edit and get the same error which is "Uncaught ReferenceError: Employee is not defined "

Sorry, didnt mentioned initially, but the goal is to use the Inline edit, and i get the error when a new row is added to the grid. 

Thanks in advance. 
Congrats for your products.

2 Answers, 1 is accepted

Sort by
0
Accepted
Vladimir Iliev
Telerik team
answered on 22 Feb 2013, 01:38 PM
Hi Ricardo,

 
You are getting this error because the Employee property of the model to which is bind the DropDownList is object. When you create new record Employee field pointer is set to null.  When the DropDownList is initialized and is bound to not-existing property the exception is thrown. To be able to create records in current scenario you should define default value for the Employee field in the following way:

Grid configuration:

.DataSource(dataSource => dataSource
    .Ajax()
    .Batch(true)
    .ServerOperation(false)
    .Events(events => events.Error("error_handler"))
    .Model(model =>
    {
        model.Id(p => p.OrderID);
        model.Field(p => p.OrderID).Editable(false);
        model.Field(p => p.Employee).DefaultValue(new Kendo.Mvc.Examples.Models.ClientEmployeeViewModel());
    })
    .Create(create => create.Action("EditingCustom_Create", "Grid"))
    .Read(read => read.Action("EditingCustom_Read", "Grid"))
    .Update(update => update.Action("EditingCustom_Update", "Grid"))
)

Also I would suggest to define OptionLabel in the ClientEmployee custom editor as follows:
@(Html.Kendo().DropDownList()
        .Name("Employee")
        .DataValueField("EmployeeID")
        .DataTextField("EmployeeName")
        .OptionLabel("Select employee")
        .BindTo((System.Collections.IEnumerable)ViewData["employees"])
)
Kind Regards,
Vladimir Iliev
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
Ricardo
Top achievements
Rank 1
answered on 26 Feb 2013, 12:15 AM
Hi Vladimir,
Thanks for the reply, i will give it a try.
Tags
Grid
Asked by
Ricardo
Top achievements
Rank 1
Answers by
Vladimir Iliev
Telerik team
Ricardo
Top achievements
Rank 1
Share this question
or