D
D
Daniel161rus2022-02-01 16:33:37
JavaScript
Daniel161rus, 2022-02-01 16:33:37

How to highlight the row or column in which the cursor is active (vue-excel-editor)?

It is necessary to highlight the row and column in which the cursor is active

<template>
    <vue-excel-editor v-model="jsondata">
        <vue-excel-column field="user"   label="User" />
        <vue-excel-column field="name"   label="Name" />
        <vue-excel-column field="phone"  label="Contact" />
        <vue-excel-column field="gender" label="Gender" />
        <vue-excel-column field="age"    label="Age" />
        <vue-excel-column field="birth"  label="Date Of Birth" />
    </vue-excel-editor>
</template>


like here ->61f938267ae9c917272182.gif

Answer the question

In order to leave comments, you need to log in

1 answer(s)
0
0xD34F, 2022-02-01
@Daniil161rus

data: () => ({
  columns: [
    { field: '...', label: '...' },
    { field: '...', label: '...' },
    ...
  ],
  focused: {},
  ...
}),
methods: {
  rowStyle(row) {
    return row === this.focused.record && {
      backgroundColor: 'red',
    };
  },
  cellStyle(row, cell) {
    return cell.name === this.columns[this.focused.colPos]?.field && {
      backgroundColor: 'orange',
    };
  },
},

<vue-excel-editor
  :row-style="rowStyle"
  :cell-style="cellStyle"
  @cell-focus="focused = $event"
  ...
>
  <vue-excel-column
    v-for="n in columns"
    v-bind="n"
    :key="n.field"
  />
</vue-excel-editor>

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question