【问题标题】:Angular 7 - Set the data source for the Select/dropdown boxAngular 7 - 为选择/下拉框设置数据源
【发布时间】:2019-08-16 19:38:19
【问题描述】:

我正在查询 API 并将数据返回到数组中。我不确定如何从 API 返回的数据响应中设置选择/下拉框的数据源。我的模型类是

 export class sProject {
  Id: string;
  prj_number: string;
  emp_number : string;
  }

我的组件是这样的

 export class RFComponent implements OnInit {
    sList: sProject[];
    entityUrl = 'sDetail/GetByRP?Prj=345';

 constructor(service: DataService) {
  service.get<sProject[]>(this.entityUrl).subscribe(x => 
  {this.stList = x });
  }
   ngOnInit() {  }}

数据在sList 数组中,我不确定如何为我的选择/下拉框设置数据源

<div class="dx-fieldset">
  <div class="dx-field">
    <div class="dx-field-label">ShipTo Account</div>
    <div class="dx-field-value">
        <dx-select-box></dx-select-box>
    </div>
  </div>
 </div>

我在这里使用的是 devextreme 库,我试图在下拉框中查看所有 prj_number。

【问题讨论】:

    标签: angular angular7 devextreme


    【解决方案1】:

    根据 devextreme website 试试这个:

    <dx-select-box [dataSource]="sList" displayExpr="prj_number "></dx-select-box>
    

    希望它有效。

    【讨论】:

    • 完美运行。你知道是否有任何方法只显示不同的值吗?
    • 试试这样的example
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-09-04
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-03-11
    • 1970-01-01
    相关资源
    最近更新 更多