2012-04-27 19 views
1

我的控制器:變化DevExpress的出口行值

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

回答

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')"; 
        });