ui-grid
ui-grid copied to clipboard
Scrolling/ Rendering broken after rowHeight change
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.
in options if change some - then not applying to grid. use row.height. in new version i add method setRowHeight in my repo
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.
+1
chek it out please in my repo
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();
}