Angular 6 handsontable, создайте выпадающий список, где значения выбираются с сервера - PullRequest
0 голосов
/ 28 сентября 2018

Я пытаюсь создать выпадающее поле в handsontable.Вот мой код:

view.html:

<hot-table
    class="hot-service"
    [data]="posts"
    [colHeaders]="true"
    [height]="525"
    [rowHeaders]="true"
    [afterChange]="detectChanges"
    [settings]="serviceSettings">
</hot-table>

Ниже приведен компонент, который я использую для получения подробностей таблицы и раскрывающегося списка.

export class PostComponent implements ngOnInit {
  posts: any[];
  employees: any[];

  serviceSettings = {
    columns: [{
        title: 'Post ID',
        type: 'text',
        data: 'post_id',
        readOnly: true
      },
      {
        title: 'Employee',
        type: 'handsontable',
        handsontable: {
          colHeaders: ['Id', 'Name'],
          autoColumnSize: true,
          data: this.employees,
          getValue: function() {
            const selection = this.getSelected();
            return this.getSourceDataAtRow(selection[0]).Name;
          },
        },
        data: 'employee'
      }
    ],
    colHeaders: true,
    rowHeaders: true,
    contextMenu: true,
    fillHandle: {
      autoInsertRow: true,
    },
  };

  constructor(
    private empService: EmployeeService,
  ) {}

  ngOnInit() {
    this.empService.getPosts()
      .subscribe(
        post_data => this.posts = post_data,
        err => console.log(err)
      );

    this.empService.getEmployees()
      .subscribe(
        emp => this.employee = emp,
        err => console.log(err)
      );
  }
}

Проблема Iсмотрю на это, выпадающий не показывает никаких значений в нем.Я подозреваю, что причина того, что при создании таблицы значение сотрудника пустое, следовательно, он создает раскрывающийся список.

Итак, как я могу обновить раскрывающийся список при получении данных из моегообслуживание

...