vue.jsvue-tables-2

Vuetable-2 field formatter not working as intended


I am using vuetable-2 and somehow the formatter for my fields does not work. The frontend for my isCoach field still shows as 1 but based on the formatter set, it should instead return Active.

Template

<vuetable
  ref="vuetable"
  api-url=""
  :query-params="makeQueryParams"
  :per-page="perPage"
  pagination-path
  data-path="Data"
  :reactive-api-url="true"
  :fields="fields"
  :row-class="onRowClass"
  @vuetable:pagination-data="onPaginationData"
  @vuetable:cell-rightclicked="rightClicked"
>

Data

fields:[
{
          name: "isCoach",
          sortField: "isCoach",
          title: "Coach",
          titleClass: "",
          dataClass: "text-muted",
          width: "5%",
          formatter: (value) => {
            return value === '1' ? 'Active' : 'Disable'
          }
        },
]

Documentation: https://www.vuetable.com/guide/fields-definition.html#field-options


Solution

  • I found the solution. Apparently formatter doesn't work. Changing it to callback solved my issue.