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

Column headers become fixed and out of sync on horizontal scroll

Open deepfriedbrain opened this issue 11 years ago • 24 comments

Column headers become fixed and go out of sync on horizontal scroll. I'm using the latest unstable release and Chrome 42x. Refer to the screenshot below.

image

deepfriedbrain avatar May 31 '15 11:05 deepfriedbrain

Can you give more details on your grid setup so this can be reproduced, i.e. what features you have turned on/off (like filtering which I see), how many columns total, grid css, etc?

Even better, a plunker with the issue reproduced would be wonderful :)

c0bra avatar Jun 02 '15 14:06 c0bra

I can't reproduce this consistently, but it happens quite frequently (I just couldn't figure out a pattern so far). I'm using ui-grid-selection and ui-grid-pinning on my grid. In the grid css, width and height are set to 100%, though it doesn't really expand the grid to 100% available screen height (that might be another issue). I have 12 columns in total. Needless to say, I have more columns than what can fit into the screen width and hence the need for horizontal scrolling. My grid has these options set on it.

        selectedItems: [],
        showGridFooter: false,
        enableRowHeaderSelection: true,
        multiSelect: false,
        enableHorizontalScrollbar: 1,
        enableVerticalScrollbar: 1,
        enableFiltering: true,
        enableSorting: true,

If you cannot reproduce it at all, let me know. I'll try to setup a plunker and see if I can reproduce it there.

Thanks to you and all the contributors for the awesome work!

deepfriedbrain avatar Jun 04 '15 14:06 deepfriedbrain

After playing around a bit, I figured out that 2 things when combined cause the problem:

  1. Enable "ui-grid-selection".
  2. Have a div with ng-show around the div for the grid, like so:
<div ng-show="someobj.length > 0">
    <div ui-grid="gridOptions" ui-grid-selection class="grid"></div>
        <!-- some more content here -->
</div>

If I replace ng-show with ng-if, the issue goes away. The issue also goes away if I remove ui-grid-selection from the grid.

I removed every option from the grid, and brought it to down to just 2 columns with a single row of hard-coded data. See the screenshot below. When I first load the page, grid works just fine. But if I refresh the page using browser's refresh button, that's when the header gets frozen. If I navigate to another page (ui router state) and come back to the original page with the grid, it starts to work fine again. But if I refresh the browser again, the issue comes back. So, it happens only after refreshing the browser.

I tried to reproduce it in plunkr but was unsuccessful.

image

For now my workaround is to use ng-if instead of ng-show. Let me know if I can do anything more to help resolve this issue.

deepfriedbrain avatar Jun 04 '15 15:06 deepfriedbrain

I have the same issue. With hg-if in the container that show it instead of ng-show, it fix the scroll but for me is too slow. Removing the ui-grid-selection directive, it works fine. If I resize the chrome tab it starts to scroll. I'm using the following directives on my grid: ui-grid-resize-columns, ui-grid-pagination, ui-grid-pinning, ui-grid-selection, ui-grid-edit, ui-grid-row-edit

darionato avatar Jun 12 '15 10:06 darionato

@deepfriedbrain Did you put that exact app in plunker? And did you try it in the full browser view rather than in the iframe with the editor?

c0bra avatar Jun 19 '15 17:06 c0bra

Yes I tried to use the full browser but still couldn't reproduce it in a plunker.

deepfriedbrain avatar Jun 21 '15 05:06 deepfriedbrain

I created a Plunker to show this strange behavior: Here the url:

http://plnkr.co/edit/7vF92f9VR8Ck5OYDfHBd?p=preview

When you run the project, ensure that the preview is smaller than the grid so the horizontal scroll is active. When you scroll the header stay locked.

Anyway it seems to be the width in the css file. If I set a fixed size it works. If I leave 100% and set the width property "scope.gridApi.grid.gridWidth", the grid change but the header not.

darionato avatar Jun 24 '15 07:06 darionato

In chrome I can't even scroll in your example. I have to use the arrow keys to scroll to the right/left. At that point it is very obvious that the headers aren't moving.

JLLeitschuh avatar Jun 24 '15 14:06 JLLeitschuh

I tried this example in chrome and firefox and I can scroll left-right.

When the example starts, shrink the preview column quite small, press the "Show/hide" button and the grid should appear with the scroll bar in the bottom.

darionato avatar Jun 24 '15 15:06 darionato

I've encountered the same behavior and the Plunkr that @darionato created does exhibit the behavior. Switching to using an ng-if instead of ng-show for now.

dprothero avatar Aug 24 '15 14:08 dprothero

I ran into this issue, but this was primarily due to the grid being hosted in a Bootstrap tab.

The duplication is that the grid is initially hidden since it is located on a non-default tab. The root cause is that ui-grid does not know how to calculate the column alignments, due to the grid being not visible in the DOM.

Funny enough, the fix has already been documented, albeit, for a slightly different reason. The key being (and modified for ng-show / Bootstrap tabs):

$rootScope.gridOptions = {
    onRegisterApi: function (gridApi) {
      $scope.gridApi = gridApi;

      $interval( function() {
        $scope.gridApi.core.handleWindowResize();
      }, 200);
      }
  };

justin-lovell avatar Feb 02 '16 13:02 justin-lovell

Further to the above, the auto-resize module implies the same behaviour as the solution: http://plnkr.co/edit/fwdXMamTBrR1yKVwcohZ?p=preview

justin-lovell avatar Feb 02 '16 13:02 justin-lovell

thank you, with this trick it works fine

darionato avatar Feb 02 '16 15:02 darionato

Thanks the above worked for me!!!

angular-git-user avatar Mar 15 '16 10:03 angular-git-user

Please read the angular docs for $interval. If you are going to execute it indefinitely, ie: with no definite number of times, you must destroy $interval, maybe when $scope is destroyed.

mgrivera avatar Mar 16 '16 14:03 mgrivera

In addition to whats said above as solution, what worked for me was, updated all the dependencies and moved to the fresh release and set the css property of 'overflow' to 'hidden' (instead of 'visible') when using this class "ui-grid-top-panel" for grid header.

saadgit avatar Oct 24 '16 12:10 saadgit

I have facing same issue in this when we click on tab(continue pressing ) button on search box on each column in grid ui on top of the header then missing alignment of the header and table data bellow image is there please help me to solve this issue

test

pawanupr16 avatar Nov 24 '16 06:11 pawanupr16

Any updates on this ??

Thanks in advance

pawanupr16 avatar Jan 11 '17 07:01 pawanupr16

Issue of ng-show still exists in ui-grid but @justin-lovell trick help me out. Thanks for this bro.

prashant93 avatar Mar 21 '17 15:03 prashant93

I am also having this issue. 100% reproducible on a grid where we set the horizontalscroll to 1 after the grid was initialized with horizontalscroll of 0.

headers become fixed and do not scroll with the data.

EDIT: nevermind. we were a version behind and updating the code base of ui-grid fixed the issue

jasonbrandt42 avatar Apr 27 '17 21:04 jasonbrandt42