[Vuejs]-How to access header index in vue-good-table

1๐Ÿ‘

โœ…

i just found it out, the answer was just in the picture

{{props.row.vgt_id}}

2๐Ÿ‘

You can get column name using props.column. props.column will give you full column object so you can get index from it. props.column.field will give you column name title.

  1. You can check index with props.column.originalIndex
  2. The original row object can be accessed via props.row
  3. The currently displayed table row index can be accessed via props.index .
  4. The original row index can be accessed via props.row.originalIndex.
  5. You can then access the original row object by using rows[props.row.originalIndex].
  6. The column object can be accessed via props.column
  7. You can access the formatted row data (for example โ€“ formatted date) via props.formattedRow

For example :

<vue-good-table
  :columns="columns"
  :rows="rows">
  <template slot="table-row" slot-scope="props">
    <span v-if="props.column.field == 'age'">
      <span style="font-weight: bold; color: blue;">{{props.row.age}}</span> 
    </span>
    <span v-else>
      {{props.formattedRow[props.column.field]}}
    </span>
  </template>
</vue-good-table>

Source

0๐Ÿ‘

try this:

{{props.row.originalIndex}}

Leave a comment