我的控制器:
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);
!!! ---- !!!
...
}
!!! ---- !!! < - 这里我要添加列。如果value为True,则此列中的行输出必须为YES;如果value为False,则此行必须为NO
答案 0 :(得分:0)
settings.Columns.Add(set =>
{
set.FieldName = "IsSomething";
set.Caption = "Is Something";
set.UnboundType = DevExpress.Data.UnboundColumnType.String;
set.UnboundExpression = "Iif([IsSomething]==True, 'Yes', 'No')";
});