Appear scroll bar although dataSource is empty

Hi Syncfusion Team,
I am using Filtering and Virtual scroll in GridComponent. After I filtered, although dataSource is empty, the scroll bar still appears.


How to I can make the scroll bar don't appear when dataSource is empty?
Link sample: https://stackblitz.com/edit/react-c5z6u4?file=index.js


Thanks,
Ton That Hung


3 Replies 1 reply marked as answer

RS Rajapandiyan Settu Syncfusion Team May 13, 2022 11:08 AM UTC

Hi Ton,


Thanks for contacting Syncfusion support.


By using the following code example in the dataBound event, we can hide the scroller when no record is displayed in the Grid.


dataBound: https://ej2.syncfusion.com/react/documentation/api/grid/#databound

hideScroll: https://ej2.syncfusion.com/react/documentation/api/grid/#hidescroll

getCurrentViewRecords: https://ej2.syncfusion.com/react/documentation/api/grid/#getcurrentviewrecords


 

[index.js]

 

  dataBound(args) {

    if ( this.grid.getCurrentViewRecords().length == 0 && this.grid.enableVirtualization) {

      this.grid.getContent().querySelector('.e-virtualtrack').style.height = 'unset';  // remove the scrollbar thumb

      this.grid.hideScroll(); // hide the scrollbar

    }

  }

 


Sample: https://stackblitz.com/edit/react-c5z6u4-kjbpgm?file=index.js


Please get back to us if you need further assistance with this.


Regards,

Rajapandiyan S


Marked as answer

TT Ton That Hung May 16, 2022 02:18 AM UTC

Thank for your solution.



RS Rajapandiyan Settu Syncfusion Team May 16, 2022 03:03 AM UTC

Hi Ton,


We are glad to hear that you have achieved your requirement with the provided solution.


Please get back to us if you need further assistance.


Regards,

Rajapandiyan S


Loader.
Up arrow icon