revogrid icon indicating copy to clipboard operation
revogrid copied to clipboard

Having trouble hiding columns and refreshing data.

Open lionsarmor opened this issue 2 years ago • 4 comments

I would like to hide columns on a button click, I am able to update the data for the columns but the data doesnt refresh, also the grid.refresh('all'), seems to do nothing, no errors or output, I am using vue2, my project was built out using example code everything seems to work except updating data.

this example I was just trying to add an additional column to test that the data was updated.

dropColumns(hide) {
  const grid = document.querySelector('revo-grid');
  grid.columns = this.columns
  if (hide == true) {
  grid.columns.push({id: 1,prop: "goob",size: 200,name: 'goober'})
  grid.refresh('all')
  }
},

lionsarmor avatar Mar 02 '22 22:03 lionsarmor

You can try: dropColumns(hide) { // const grid = document.querySelector('revo-grid'); // grid.columns = this.columns // setting columns one-time in v-grid tag by property ":columns="columns"" image

if (hide == true) { var tempCols = this.columns tempCols .push({id: 1,prop: "goob",size: 200,name: 'goober'}) this.columns = [...tempCols] // for update columns // grid.refresh('all') } },

van-huyen avatar Mar 07 '22 02:03 van-huyen

Thank you I think I understand this. I'll update a second array and just replace the old one.

lionsarmor avatar Mar 07 '22 02:03 lionsarmor

@lionsarmor @van-huyen is totally right. The whole grid concept is based on mutations. Use data-driven approach instead of methods. Use mutations and it will refresh things automatically.

revolist avatar Mar 07 '22 11:03 revolist

I think what the problem is, that I am actually facing is, I replace the data in columns and rows, it does update, the column headers, but only the first row seems to change leaving the old data, but this concept here works, so I must have a bug some place. thank you

lionsarmor avatar Mar 07 '22 18:03 lionsarmor