I'm using a Grid.Mvc control and I'm not able to display List values in a singular column. I'm using the following code. The problem occurs in the column "Documenten".
@(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")
)
The model contains a variable called "Files" (List) in which the file class consists of an Id (Guid) and Name (string). I need these values in the Actionlink to display the filename and Id for downloading the file. Is it possible to do this in the Grid.Mvc control (http://mvc6-grid.azurewebsites.net)?
The model i'm using:
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; }
}
}
Thanks for your help.
File is list so you can't use it like a property.
You can use http://mvc6-grid.azurewebsites.net/Grid/Partial for file list.