我的控制器:
public ActionResult ExportTo(ExportFormat exportFormat = ExportFormat.Xlsx)
{
ExportType exportType = GridViewHelper.ExportTypes.SingleOrDefault(x => x.Format == exportFormat);
if (exportType != null)
{
var modelList= modelRepository.GetAll();
var gridviewSettings = CreateExportGridViewSettings();
if(gridviewSettings != null)
return exportType.Method(gridviewSettings, modelList);
}
return RedirectToAction("Index");
}
...
private GridViewSettings CreateExportGridViewSettings()
{
var settings = new GridViewSettings
{
Name = "Export",
CallbackRouteValues = new {Controller = "MyController", Action = "List"},
Width = Unit.Percentage(100)
};
settings.Columns.Add("Id", Resources.Id);
!!! ---- !!!
...
}
!!!---- !!! <- 在这里我想添加列。如果值为 True,则此列中的行输出必须为 YES,如果值为 False,则必须为 NO