[Vuejs]-VueGoodTable filter dropdown options vue2

0👍

You can make the table update after it’s rendered by making columns a computed property. The other problem you have is this.customers is an Array but Object.values() expects an Object. You could use the Array.map function instead

this.customers.map(c => c.value)

Although according to the VueGoodTable docs an array of objects like you have should work just fine

computed: {
  columns() {
    return [
      {
        label: 'some column',
        field: 'column1'
      },
      {
        label: 'Customer',
        field: 'customerName',
        filterOptions: {
          enabled: true,
          placeholder: 'All',
          filterDropdownItems: this.customers
        }
      },
      {
        label: 'other columns',
        field: 'column234'
      }
    ];
  }
}

Leave a comment