I've inherited someone else's vue code that uses vue-tables-2. The table looks like this (very, very simplified)...
<v-client-table :data="myRows" :columns="columns" :options="options">
<div slot="columnA" slot-scope="{row}">
<input type="text" v-model.trim="row.someKey" class="form-control">
</div>
<div slot="etc"> ...
Notice how it says slot-scope="{row}"
, instead of slot-scope="row"
. As I inspect rows, I find each row looks like this...
{ row: { keyA: value, keyB: value, etc }, index: 1 },
{ row: { keyA: value, keyB: value, etc }, index: 2 }, etc
So I guess the original author "destructured" the row to avoid wasting keystrokes, as in v-model.trim="row.row.someKey"
.
Now I'm adding a new column which uses the row and the array index of the row data, like this...
<div slot="columnZ" slot-scope="row">
<p>col value is {{row.row.someOtherKey}} and index is {{row.index-1}}<p>
</div>
But I don't like row.row
any better than the original author, and the row.index
is given in counting numbers, not the zero-based array index.
I assume vue-tables-2 is the source of both of these issues. Is there a way I can use the package but just get the row data without having it wrapped in another "row", and is there a way I can get a zero-based array index per row?