Vue-good-table: Change row color on mouse events

Created on 9 Oct 2018  路  4Comments  路  Source: xaksis/vue-good-table

Issue Type

  • [x] Question

Specs

What version are you using?
2.14.6

What browser?
Chrome

Question

I would like to change the color of a whole row when I overlay it and in a different color when I double-click on it.

After searching the documentation, I've been using @on-row-dblclick and @on-row-mouseenter so far but didn't find examples on how to change the color.

Thank you for your help
S.

Most helpful comment

@sylvaincaillot You can check for the 'vgtSelected' boolean property and toggle your styling accordingly. This property exists in each row when ':select-options' is enabled.

Example:

rowStyleClassFn(row){
  return row.vgtSelected ? 'VGT-row _dblclick' : 'VGT-row';
}
<style scoped>
.VGT-row:hover {...}
.VGT-row._dblclick {...}
</style>

All 4 comments

hey @sylvaincaillot you can use rowStyleClass, https://xaksis.github.io/vue-good-table/guide/configuration/#rowstyleclass

just use a function for rowStyleClass and conditionally put a class on the row that matches the row that you're hovering over, or double clicking on.

closing.

Thank you @xaksis, it works well with mouse over:

rowStyleClassFn(row) {
      return 'VGT-row';
    },

with the following CSS:

<style scoped>
.VGT-row:hover {
    background-color: yellow;
  }
</style>

However, I don't see how to use the @on-row-dblclick to change dynamicaly the class for the row. Would you have any examples?

Thank you

@sylvaincaillot You can check for the 'vgtSelected' boolean property and toggle your styling accordingly. This property exists in each row when ':select-options' is enabled.

Example:

rowStyleClassFn(row){
  return row.vgtSelected ? 'VGT-row _dblclick' : 'VGT-row';
}
<style scoped>
.VGT-row:hover {...}
.VGT-row._dblclick {...}
</style>

As a sidenote, if your row is clickable because of the '@on-row-click' property on the table, the row gets a hover color from the default styles.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

dariagrudzien picture dariagrudzien  路  3Comments

davidjr82 picture davidjr82  路  6Comments

sylvaincaillot picture sylvaincaillot  路  3Comments

oflittlemother picture oflittlemother  路  6Comments

jannishuebl picture jannishuebl  路  3Comments