DevExpress DxGrid。连接到一列中的数据集中的值

问题描述 投票:0回答:1

我正在使用 EntityFrameworkCore 通过服务加载数据并将数据显示到 DxGrid 中。我需要将数据中的项目合并、连接或串联到一列中。我正在开发 DevExpress Blazor 模板。

这是我加载数据的方式。 PublicacionesService 是我的服务,它被注入到我的 .razor 页面上,并在 Program.cs 中声明

   IGrid Grid { get; set; }
   protected override async Task OnAfterRenderAsync(bool firstRender)
   {
    await Task.Delay(1000);
    GridData = await PublicacionesService.ViewPublicaciones.ToListAsync();
 
    PanelVisible = false;
    StateHasChanged();
  
   }

然后我就有了这个组件

   <DxGrid @ref="Grid"
     Data="GridData"
     EditMode="GridEditMode.EditRow"
     CssClass="mw-1100"
     CustomizeElement="Grid_CustomizeElement"
     @oncontextmenu:preventDefault
     EditModelSaving="Grid_EditModelSaving"
     DataItemDeleting="Grid_DataItemDeleting">

     <Columns>
     <DxGridDataColumn FieldName="Numero" Caption="Ver" Width="40px" />

     <DxGridDataColumn " Caption="Expediente"/> // What I expect ExpteNro / ExpteAnio

     <DxGridDataColumn FieldName="Objeto" DisplayFormat="D" Caption="Objeto" />
     <DxGridDataColumn FieldName="Descripcion" Caption="Descripcion" />
     <DxGridDataColumn FieldName="Fecha" Caption="Fecha" Width="140px" />
     </Columns>
    </DxGrid>

在 DxGridDataColumn 中,我需要将 ExpteNro 和 ExpteAnio 放入一列中。 这是我的课

   public partial class ViewPublicaciones
    {
      public long Id { get; set; }

      public int? ExpteNro { get; set; }

      public int? ExpteAnio { get; set; }

      public DateTime? FechaPres { get; set; }

    }
devexpress calculated-columns dxgrid
1个回答
0
投票

好的。我采取了简单的方法,我不确定使用其他东西是否会有所不同。

  public partial class ViewPublicaciones
{
  public long Id { get; set; }

  public int? ExpteNro { get; set; }

  public int? ExpteAnio { get; set; }

  public DateTime? FechaPres { get; set; }

   public string ExpteNroAnio => $"{ExpteNro.ToString() } / 
   {ExpteAnio.ToString()} ";
}

  <DxGridDataColumn FieldName="ExpteNroAnio" Caption="Expediente" 
   Width="120px" />

如果有人发现其他东西,请自由分享。叽叽叽.

© www.soinside.com 2019 - 2024. All rights reserved.