Virtualized grid doesn't display properly when changing height

On a grid with virtualization enabled, if the grid height is changed, then the grid doesn't display properly.

Here is a sandbox example:

https://codesandbox.io/s/syncfusion-virtual-grid-change-height-8q79c?file=/src/components/Grid.vue

If you scroll to the bottom of the grid, and then scroll back to the top, you'll see a big margin at the top. Below is a screenshot. The use-case for this scenario is to automatically resize the grid to fit the screen.

Screen Shot 2021-11-14 at 12.36.33 PM.png


4 Replies

BN Bill Naples November 16, 2021 08:05 PM UTC

Hi, any update on this issue? It repros on 19.3, as shown in attached zip. Thanks.


Attachment: SyncFusion_19.3_Grid_Virtualization_78609ca0.zip


AG Ajith Govarthan Syncfusion Team November 17, 2021 02:07 AM UTC

Hi Bill Naples, 

Thanks for contacting Syncfusion support. 

We have checked your sample and found that you have changed the Grid component height dynamically in your Grid application. By default, in our EJ2 Grid the virtualScroll feature will work based on the Grid component height and pageSize

So, when you change the Grid component height as 500, the default pageSize 12 will be very small to show the current page records in the changed height. So, load the records without any white space, we suggest you set the a large amount of pageSize as per the height of the Grid component. For your convenience, we have attached the sample, please refer them for your reference. 

Code Example: 
App.vue 

<template> 
  <div> 
    <ejs-grid 
      ref="grid" 
      :columns="columns" 
      :dataSource="rows" 
      :enableVirtualization="true" 
      :allowResizing="true" 
      :height="height" 
      :pageSettings="pageSettings" 
    /> 
  </div> 
</template> 
<script> 
import Vue from "vue"; 
import { GridPlugin, Resize, VirtualScroll } from "@syncfusion/ej2-vue-grids"; 

Vue.use(GridPlugin); 

export default { 
  name: "Grid", 
  data() { 
    return { 
      height: 200, 
      pageSettings: { pageSize: 30 }, set the pageSize as per the height 
      rows: [...Array(55550).keys()].map((index) => ({ 
        name: "John Doe", 
        location: "London", 
        purchase: 5, 
      })), 
    }; 
  }, 
  computed: { 
    columns() { 
      return [ 
        { 
          field: "name", 
          headerText: "Name", 
        }, 
        { 
          field: "location", 
          headerText: "Location", 
        }, 
        { 
          field: "purchase", 
          headerText: "Purchase", 
        }, 
      ]; 
    }, 
  }, 
 provide: { 
    grid: [Resize, VirtualScroll], 
  }, 
  mounted() { 
    setTimeout(() => { 
      var grid = document.getElementsByClassName("e-grid")[0].ej2_instances[0]; 
      grid.height = 500; 
    }, 1000); 
  }, 
}; 
</script> 


Please get back to us if you need further assistance. 

Regards, 
Ajith G. 



BN Bill Naples November 17, 2021 03:33 PM UTC

Thank you Ajith. That appears to resolve that issue. However, the performance with virtualization seems to have degraded. I have to try to put together a minimal reproducible example, and sent the sample code to 



AG Ajith Govarthan Syncfusion Team November 18, 2021 06:56 AM UTC

Hi Bill Naples, 

Thanks for the update. 

We will wait to hear from you. 

Regards, 
Ajith G. 


Loader.
Up arrow icon