Hi, I have been in this problem for too long. The Foreign Key Column doesn't render a DropDownList, instead of that, it renders an <input>. I don't know why. I've been through many forums but without success. Please help me. I have the following structure.
The model and view:
Also, GridForeignKey.cshtml is in the correct place ~/Views/Shadres/EditorTemplates. I really don't know why an <input> appears. I've even tried to write my own custom editor template but I've got the same error. Help please.
The model and view:
public
class
ProcesoEvaluacionDTO
{
[ScaffoldColumn(
false
)]
public
int
ID {
get
;
set
; }
[Required]
[MaxLength(200)]
public
string
Nombre {
get
;
set
; }
[DisplayName(
"Fecha de cierre a evaluadores"
)]
[Required]
[DataType(DataType.Date), DisplayFormat(DataFormatString =
"{0:dd/MM/yyyy}"
, ApplyFormatInEditMode =
true
)]
public
string
FechaCierre {
get
;
set
; }
[Required]
[UIHint(
"GridForeignKey"
)]
[DisplayName(
"Autorizado por"
)]
public
int
AutorizadorID {
get
;
set
; }
public
ProcesoEvaluacionDTO() { }
}
public
class
ColaboradorDTO
{
public
string
NombreCompleto {
get
;
set
; }
public
int
ID {
get
;
set
; }
public
ColaboradorDTO() { }
}
@{
IList<ColaboradorDTO> colaboradores = ViewBag.colaboradores;
SelectList lista =
new
SelectList(colaboradores,
"ID"
,
"NombreCompleto"
);
}
@(Html.Kendo().Grid<ProcesoEvaluacionDTO>()
.Name(
"ProcesosDeEvaluacionGrid"
)
.Columns(columns =>
{
columns.ForeignKey((p => p.AutorizadorID), lista);
columns.Bound(p => p.Nombre);
columns.Bound(p => p.FechaCierre);
columns.Command(command => {
command.Edit();
command.Destroy();
}).Width(300);
}
)
.ToolBar(toolbar => toolbar.Create())
.Editable(editable => editable
.Mode(GridEditMode.PopUp)
)
.Pageable(paper => paper.Refresh(
true
))
.Filterable()
.Sortable()
.Scrollable(w => w.Height(330))
.DataSource(dataSource => dataSource
.Ajax()
.PageSize(20)
.ServerOperation(
false
)
.Events(events => events.Error(
"error_handler"
))
.Model(model => { model.Id(p => p.ID); })
.Create(update => update.Action(
"EditingInline_Create"
,
"ProcesoEvaluacion"
))
.Read(read => read.Action(
"EditingInline_Read"
,
"ProcesoEvaluacion"
))
.Update(update => update.Action(
"EditingInline_Update"
,
"ProcesoEvaluacion"
))
.Destroy(update => update.Action(
"EditingInline_Destroy"
,
"ProcesoEvaluacion"
))
)
)