ui-grid icon indicating copy to clipboard operation
ui-grid copied to clipboard

Scrolling/ Rendering broken after rowHeight change

Open kevinralph opened this issue 8 years ago • 5 comments
trafficstars

Changing gridOptions.rowHeight after grid has already rendered throws off scrolling. The grid seems to still be trying to calculate scrolling/rendering based on the old row height.

Maybe this isn't actually an issue and I'm just missing something in the docs. I haven't seen anything related to this and using refresh() doesn't help.

kevinralph avatar Nov 22 '16 19:11 kevinralph

in options if change some - then not applying to grid. use row.height. in new version i add method setRowHeight in my repo

cybermerlin avatar Dec 21 '16 12:12 cybermerlin

I'm seeing this behavior as well.

I've traced it a little. As you scroll, margin-top of the top row increases with every scroll, the rowHeight value multiple by the row you're on. eg, if you scroll down and you're at index 2 (row 3), the margin-top of the first row gets set to rowHeight * 2.

This is happening in the controller for the uiGridViewport directive, specifically the rowStyle() function.

I'm not sure what to do at this point though.

umdstu avatar Mar 01 '17 19:03 umdstu

+1

Sogmog avatar Jul 18 '17 10:07 Sogmog

chek it out please in my repo

cybermerlin avatar Jul 27 '17 18:07 cybermerlin

This is super broken. However, in order to save some others from some of the torture I've faced because changing the rowHeight doesn't work even in 4.8.0, you can do this:

// Sure, go ahead and set your row height. However, that doesn't make things work because 
// UI Grid has pushed the height down to every single row.
this.gridOptions.rowHeight = 54;

// So you need to make the call to notify of the data change (which does nothing, but might get 
// fixed some day), and then modify all of the rows individually to have a new height and 
// queue a refresh.
if (this.gridApi) {
  this.gridApi.core.notifyDataChange(this.uiGridConstants.dataChange.OPTIONS);

  // Hopefully we can remove both of these later because the UI Grid will notice the rowHeight change
  // at the options level and fix all the rows for us.
  let visibleRows = this.gridApi.core.getVisibleRows(this.gridApi.grid);
  visibleRows.forEach(row => row.height = this.gridOptions.rowHeight);

  this.gridApi.core.queueGridRefresh();
}

JohnMunsch avatar Jun 03 '19 19:06 JohnMunsch