显示 table 行中列的下拉列表

Showing Drop down for column in a row of table

我使用 DevExtreme 模块创建了一个 table 并找到以下代码

<div id="data-grid">
  <div id="data-grid-table">
    <dx-data-grid id="gridContainer" keyExpr="emailId"  [dataSource]="userAccessList" [allowColumnReordering]="true" (onRowUpdated)="onRowUpdated($event)" (onRowRemoved)="onRowRemoved($event)" [showRowLines]="true" [showBorders]="true">
      <dxo-editing mode="row" refreshMode="repaint" [allowUpdating]="true" [allowDeleting]="true" [useIcons]="true"></dxo-editing>
      <dxi-column dataField="emailId" alignment="center" [allowEditing]="false" ></dxi-column>
      <dxi-column dataField="name" alignment="center" caption="name">
      </dxi-column>
      <dxi-column dataField="Designation" alignment="center" caption="Designation" [width]="100">
      </dxi-column>
    </dx-data-grid>
  </div>
</div>

上面显示正常,但是当我点击编辑图标时,名称字段显示输入字段,但我需要下拉列表。

有人帮我解决这个问题吗?

提前致谢。

使用 <dxo-lookup> 和名称列表作为 dataSource:

<dxi-column dataField="name" alignment="center" caption="name">
    <dxo-lookup [dataSource]="listOfNames"></dxo-lookup>
</dxi-column>

注意:如果你的名字是一个对象而不是字符串(比如listOfNames = [ {firstname: '', lastname: ''}, ... ]),你可以显示和使用对象的特定属性如下所示:

<dxi-column dataField="name" alignment="center" caption="name">
    /**Uses the firstname as the value selected and as the value displayed in the dropdown list*/
    <dxo-lookup [dataSource]="listOfNames" valueExpr="firstname" displayExpr="firstname"></dxo-lookup>
</dxi-column>