2016-12-22 1 views
0

J'utilise un contrôle Grid.Mvc et je ne parviens pas à afficher les valeurs List dans une colonne singulière. J'utilise le code suivant. Le problème se produit dans la colonne "Documenten".Affichage des valeurs List dans la colonne du contrôle Grid.Mvc

@(Html 
.Grid(Model.Candidates) 
.Build(columns => 
{ 
    columns.Add(model => model.FullName).Titled("Name"); 
    columns.Add(model => model.Location).Titled("Locatie"); 
    columns.Add(model => model.Email).Titled("Contact").Encoded(false).RenderedAs(model => model.Email + "<br/>" + model.PhoneNumber); 
    columns.Add(model => model.Notes).Titled("Notities"); 
    columns.Add(model => model.Status).Titled("Status"); 
    columns.Add(model => model.CandidateprofilesInGrid).Titled("Profiel(en)"); 
    columns.Add(model => model.Created.Date).Titled("Aangemaakt").Encoded(false).RenderedAs(model => model.Created.Day + "-" + model.Created.Month + "-" + model.Created.Year); 
    columns.Add(model => model.Modified.Date).Titled("Gewijzigd").Encoded(false).RenderedAs(model => model.Modified.Day + "-" + model.Modified.Month + "-" + model.Modified.Year); 
    columns.Add(model => model.Moderator).Titled("Door"); 
    columns.Add(model => model.Files).Titled("Documenten").Encoded(false).RenderedAs(model => model.Files.Any() ? model.Files.ForEach(file => Html.ActionLink(file.Name, "File", new { id = file.Id })): "?"); 

    columns.Add(model => model.Id).Titled("").Filterable(false).Encoded(false).RenderedAs(model => Html.ActionLink("edit", "Edit", new { id = model.Id })); 
    columns.Add(model => model.Id).Titled("").Filterable(false).Encoded(false).RenderedAs(model => Html.ActionLink("delete", "Delete", new { id = model.Id }, new { onclick = "return confirm('Weet u zeker dat u " + model.FirstName + " wilt verwijderen?');" })); 
}) 
.Filterable() 
.Pageable() 
.Sortable() 
.Empty("Geen gegevens gevonden") 

)

Le modèle contient une variable appelée "Fichiers" (Liste) dans laquelle la classe de fichier se compose d'un identifiant (Guid) et le nom (string). J'ai besoin de ces valeurs dans le lien Action pour afficher le nom de fichier et l'ID pour télécharger le fichier. Est-il possible de le faire dans le contrôle Grid.Mvc (http://mvc6-grid.azurewebsites.net)?

Le modèle que je utilise:

public class ListCandidateViewModel 
{ 
    public IEnumerable<CandidateViewModel> Candidates { get; set; } 

    public IEnumerable<FunctionalProfile> FunctionalProfiles { get; set; } 
} 

public class CandidateViewModel 
{ 
    public CandidateViewModel() 
    { 
     Files = new List<File>(); 
    } 

    public Guid Id { get; set; } 
    public DateTime Created { get; set; } 
    public DateTime Modified { get; set; } 
    public string Moderator { get; set; } 
    public string FirstName { get; set; } 
    public string MiddleName { get; set; } 
    public string LastName { get; set; } 
    public string Schooling { get; set; } 
    public int FinishingYear { get; set; } 
    public string Location { get; set; } 
    public string PhoneNumber { get; set; } 
    public string Email { get; set; } 
    public string Status { get; set; } 
    public string Notes { get; set; } 
    public string FullName { get; set; } 
    public string CandidateprofilesInGrid { get; set; } 
    public List<File> Files { get; set; } 
} 

public class File 
{ 
    public Guid Id { get; set; } 
    public string Name { get; set; } 
    public string ContentType { get; set; } 
    public byte[] Content { get; set; } 

    public virtual ICollection<CandidateFile> CandidateFiles { get; set; } 
} 

}

Merci pour votre aide.

Répondre