[Vuejs]-Vuex – Mutating state with row data of bootstrap table when clicking a row

0πŸ‘

βœ…

I’m assuming you’re using Bootstrap Vue here, the component props look similar.

The b-table component here, with the row-clicked event returns three arguments.

  1. the row data
  2. index of the row
  3. the native event object

You need to rewrite your action and mutation to use that row data returned with the event and update the state. Code follows.

Action:

setRow: function ({commit}, rowData) {
      commit('setRowToState', rowData)
    }

Mutation:

setRowToState (state, rowData) {
      state.addeditproduct.name = rowData.name
      state.addeditproduct.description = rowData.description
      state.addeditproduct.externalid = rowData.externalid
      state.addeditproduct.active = rowData.active
      state.addeditproduct.id = rowData.id
    },
πŸ‘€Nishant Arora

Leave a comment