【问题标题】:how to access header index in vue-good-table如何访问 vue-good-table 中的标头索引
【发布时间】:2019-05-21 15:30:22
【问题描述】:

如何在分组表中访问这些标头的索引?

table_screenshot

【问题讨论】:

  • 请添加一些您的代码,以便我们了解更多

标签: vue.js vue-good-table


【解决方案1】:

我才发现,答案就在图片中

{{props.row.vgt_id}}

【讨论】:

    【解决方案2】:

    您可以使用props.column 获取列名。 props.column 将为您提供完整的列对象,以便您可以从中获取索引。 props.column.field 会给你列名title

    1. 您可以使用props.column.originalIndex检查索引
    2. 原来的行对象可以通过props.row访问
    3. 当前显示的表格行索引可以通过props.index访问。
    4. original row index 可以通过props.row.originalIndex 访问。
    5. 然后您可以使用rows[props.row.originalIndex] 访问原始行对象
    6. 列对象可以通过props.column访问
    7. 您可以通过props.formattedRow 访问格式化的行数据(例如 - 格式化的日期)

    例如:

    <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

    【讨论】:

    • @JielNiñoGaid props.column 将为您提供完整的列对象,以便您从中获取索引。
    • @JielNiñoGaid 你可以通过props.column.originalIndex查看它
    • 还是谢谢了,但是图片中的标题不是一列,而是一行...见分组表...
    • 如果是row,可以使用props.row.originalIndex
    • @JielNiñoGaid 当前显示的表格行索引可以通过props.index访问
    猜你喜欢
    • 2021-11-13
    • 1970-01-01
    • 1970-01-01
    • 2020-12-25
    • 2019-03-31
    • 2019-03-16
    • 1970-01-01
    • 2020-03-13
    • 2021-07-22
    相关资源
    最近更新 更多