Dears
I'm facing this problem: in an MVC Grid, setted with InCell editing, I have a Foreign Key column. When I edit the FK cell the DDL is not showed.
I checked the documentation and for me it is all ok.
Here some details:
[GRID DEFINITION]
@(Html.Kendo().Grid<MCP310.Models.MCP_Detail>()
.Name("Grid_MCP_Detail_" + Model.id)
.ToolBar(toolbar =>
{
toolbar.Create();
toolbar.Save();
})
.Columns(columns =>
{
columns.Bound(c => c.id).Hidden(true);
columns.Command(command => command.Destroy().IconClass("k-icon k-i-delete").Text(" ")).Width(56).MinResizableWidth(56);
columns.Bound(c => c.codiceInterno).Width(200).Sticky(true);
columns.Group(g => g
.Title("A cura del personale Marketing o dei Service Specialist Supervisor")
.Columns(mkss =>
{
mkss.Bound(c => c.descrizione).Width(300);
mkss.ForeignKey(c => c.UMBase, ds => ds.Read(r => r.Action("unitaMisura", "MCPDetailGrid")), "idMSEHI", "descrMSEHL").Width(300);
//mkss.Bound(c => c.UMBase).Width(300);
mkss.Bound(c => c.gruppoMerci).Width(300);
mkss.Bound(c => c.lineaProdotto).Width(300);
mkss.Bound(c => c.codiceTipo).Width(300);
mkss.Bound(c => c.voceCE).Width(300);
mkss.Bound(c => c.codiceValore).Width(300);
mkss.Bound(c => c.gestLottiMatricola).Width(300);
mkss.Bound(c => c.codiceEDMA).Width(150);
mkss.Bound(c => c.nomeFornitore).Width(150);
mkss.Bound(c => c.codiceProdottoFornitore).Width(150);
mkss.Bound(c => c.codiceCategoriaFornitore).Width(150);
mkss.Bound(c => c.pezziConf).Width(150);
mkss.Bound(c => c.infiammabile).Width(150);
mkss.Bound(c => c.ghiaccioSecco).Width(150);
mkss.Bound(c => c.ggMinEntrata).Width(150);
mkss.Bound(c => c.ggMinUscita).Width(150);
mkss.Bound(c => c.UMVendita).Width(150);
mkss.Bound(c => c.rapportoUMBV).Width(150);
mkss.Bound(c => c.royalty).Width(150);
}));
columns.Group(g => g
.Title("A cura del Controllo di Gestione")
.Columns(ctgs =>
{
ctgs.Bound(c => c.costoAcquisto).Title("Costo acquisto").Width(150);
ctgs.Bound(c => c.valutaFatturazione).Title("Valuta di fatturazione").Width(150);
ctgs.Bound(c => c.codValuta).Title("Cod. Valuta").Width(150);
ctgs.Bound(c => c.prezzoMinimo).Title("Prezzo Minimo").Width(150);
ctgs.Bound(c => c.percProvvMinima).Title("% Provv minima").Width(150);
ctgs.Bound(c => c.prezzoSuggerito).Title("Prezzo Suggerito").Width(150);
}));
columns.Group(g => g
.Title("A cura del MKTG o dei SSS")
.Columns(mkss =>
{
mkss.Bound(c => c.costoAcquisto).Title("Costo acquisto").Width(150);
mkss.Bound(c => c.valutaFatturazione).Title("Valuta di fatturazione").Width(150);
mkss.Bound(c => c.codValuta).Title("Cod. Valuta").Width(150);
mkss.Bound(c => c.prezzoMinimo).Title("Prezzo Minimo").Width(150);
mkss.Bound(c => c.percProvvMinima).Title("% Provv minima").Width(150);
mkss.Bound(c => c.prezzoListino).Title("Prezzo Listino").Width(150);
mkss.Bound(c => c.percProvvMassima).Title("% Provv max").Width(150);
}));
columns.Group(g => g
.Title("A cura di AAT")
.Columns(aat =>
{
aat.Bound(c => c.codiceWindSat).Title("Cod. Winsat").Width(150);
}));
columns.Bound(c => c.idStato).Title("Stato").Width(150);
})
.Editable(editable => {
editable.Mode(GridEditMode.InCell);
editable.CreateAt(GridInsertRowPosition.Bottom);
})
.Sortable()
.Scrollable()
.Resizable(resizable => resizable.Columns(true))
.Filterable()
.DataSource(dataSource => dataSource
.Ajax()
.Batch(true)
.ServerOperation(false)
.Events(events => events.Error("error_handler"))
.Model(model => model.Id(p => p.id))
.Read(action => action.Action("Read", "MCPDetailGrid", new { idHeader = Model.id }))
.Create(action => action.Action("Create", "MCPDetailGrid", new { idHeader = Model.id }))
.Update(action => action.Action("Update", "MCPDetailGrid"))
.Destroy(action => action.Action("Destroy", "MCPDetailGrid"))
)
.NoRecords("Nessun prodotto presente")
.Navigatable()
)}
[~/Views/Shared/EditorTemplates/GridForeignKey.cshtml]
@(
Html.Kendo().DropDownListFor(m => m)
.BindTo((SelectList)ViewData[ViewData.TemplateInfo.GetFullHtmlFieldName("") + "_Data"])
.ValuePrimitive(true)
)
I tried with/without ValuePrimitive and with/without @model object
[Models]
Where the data are used:
[MetadataType(typeof(MCP_DetailMetaData))]public partial class MCP_Detail: IDisposable
{
private MCPEntities MCPDB = new MCPEntities();
public class MCP_DetailMetaData
{
public int id { get; set; }
public int idMCP { get; set; }
[Required, MaxLength(10), DisplayName("Codice Interno")]
public string codiceInterno { get; set; }
[Required, MaxLength(40), DisplayName("Descrizione")]
public string descrizione { get; set; }
[Required, DisplayName("U.M. Base")]
public string UMBase { get; set; }
[Required, MaxLength(3), DisplayName("Gr. Merci")]
....
Where the data come from:
public partial class MCP_Unita_Misura
{
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2214:DoNotCallOverridableMethodsInConstructors")]
public MCP_Unita_Misura()
{
this.MCP_Detail = new HashSet<MCP_Detail>();
}
public string idMSEHI { get; set; }
public string idMSEH3 { get; set; }
public string idMSEH6 { get; set; }
public string MSEHT { get; set; }
public string descrMSEHL { get; set; }
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly")]
public virtual ICollection<MCP_Detail> MCP_Detail { get; set; }
}
[Other]
The FK exists also in the DB and in the Model
Thanks in advance
Cristian