Horizontal scrollbar on top and bottom of the grid

I have a grid with a lots of data and there are cases where having a horizontal scrollbar on top of the grid along with the existing one at the bottom will be helpful to end users. I was wondering if there is any way to implement this - horizontal scrollbar in Syncfusion Angular in Blazor as well.

Any help would be very much appreciated.


25 Replies

NP Naveen Palanivel Syncfusion Team June 15, 2022 05:54 PM UTC

Hi Nick,  


Sorry for the Inconvenience.


We are currently Validating  the reported query at our end and we will update the further details within two business days(June 17, 2022). Until then we appreciate your patience.


Regards,

Naveen Palanivel.



NP Naveen Palanivel Syncfusion Team June 17, 2022 05:49 PM UTC

Hi Nick,


Greetings from Syncfusion support.


We checked your Query , you want scrollbar on top and Bottom. We achieved your requirement by javascript and we prepared sample attached in this ticket. Please refer the attached sample for your reference.


Kindly get back to us if you have further queries.


Regards,

Naveen Palanivel.


Attachment: HorizontalScroll_3ff60fc3.zip


NI Nick replied to Naveen Palanivel June 17, 2022 06:43 PM UTC

The horizontal scrollbar works except when one of the column is frozen. Please take a look at the attached sample.


Attachment: ScrollTest_b4f9866f.zip


NP Naveen Palanivel Syncfusion Team June 20, 2022 04:20 PM UTC

Hi Nick,


We checked your Query , you want scrollbar on top and Bottom works except when one of the column is frozen. We achieved your requirement by javascript and we prepared sample attached in this ticket. Please refer the attached sample for your reference.


Kindly get back to us if you have further queries.


Regards,

Naveen Palanivel.


Attachment: ScrollTest_(2)_2614e546.zip


NI Nick replied to Naveen Palanivel June 21, 2022 02:42 PM UTC

I have two queries:

  1. The top scrollbar stays even when the width of the grid content is less than the width of the grid.TopScroll.PNG 
  2. I don't know if you need me to create a new thread for this but I saw that using the Column Chooser does not acknowledge the TextWrap​ mode after being refresh. In the picture below, Main Fields column does not have autofit but the text wrap property is not added.TextWrap.PNG

Attachment: ScrollTest_a30d44d9.zip


NP Naveen Palanivel Syncfusion Team June 22, 2022 05:04 PM UTC

Hi Nick,  


Sorry for the Inconvenience.


We are currently Validating  the reported query at our end and we will update the further details within two business days(June 24, 2022). Until then we appreciate your patience.


Regards,

Naveen Palanivel.



NP Naveen Palanivel Syncfusion Team June 27, 2022 05:06 AM UTC

Hi Nick,  


Sorry for the Inconvenience.


We are currently Validating  the reported query at our end and we will update the further details within one  business days(June 28, 2022). Until then we appreciate your patience.


Regards,

Naveen Palanivel.



VN Vignesh Natarajan Syncfusion Team June 29, 2022 05:56 AM UTC

Hi Nick,


Sorry for the delay in getting back to you.


Query1: “The top scrollbar stays even when the width of the grid content is less than the width of the grid.


We are able to reproduce the reported issue at our end also. We have resolved the reported issue by making the changes in the JavaScript scroll method. Refer to the modified sample in the attachments for your reference


Please get back to us if you have further queries.


Query2: “n the picture below, Main Fields column does not have autofit but the text wrap property is not added.


By default cell text will be wrapped only when column content exceeds column width. But in the attached sample, you have defined the Grid component width as 1200 pixels and on hiding all other columns using column chooser. In the movable part, only the Main Fields column alone exist and its width will be auto-adjusted to the remaining space in the Grid. Hence the Text wrap is not applied to that column when all other columns were hidden.


This is the default behavior of Grid.


Regards,

Vignesh Natarajan


Attachment: ScrollTest_7e17f036.zip


NI Nick replied to Vignesh Natarajan July 5, 2022 08:40 PM UTC

I am coming across another issue where the top scrollbar doesn't adjust when re-ordering is done when columns freeze is true, like shown in the image below.

Frozen-column-reorder.PNG



NP Naveen Palanivel Syncfusion Team July 7, 2022 05:45 PM UTC

Hi Nick,  


Sorry for the Inconvenience.


We are currently checking the reported case at our end and we will update the further details in three business day as promised (July 12, 2022). Until then we appreciate your patience. 


Regards,

Naveen Palanivel



NP Naveen Palanivel Syncfusion Team July 13, 2022 05:31 PM UTC

Hi Nick,  


Sorry for the Inconvenience.


We are currently checking the reported case at our end and we will update the further details in three business day as promised (July 18, 2022). Until then we appreciate your patience. 


Regards,

Naveen Palanivel



NI Nick July 20, 2022 01:47 PM UTC

When can I expect an update on this?



NP Naveen Palanivel Syncfusion Team July 21, 2022 04:26 AM UTC

Hi Nick,


Sorry for the Inconvenience.


We checked your Query , you facing the issue when top scrollbar doesn't adjust when re-ordering is done when columns freeze is true,. We achieved your requirement by javascript and we prepared sample attached in this ticket. Please refer the attached sample for your reference.


Kindly get back to us if you have further queries.


Regards,

Naveen Palanivel.


Attachment: ScrollTest_latest_b8112a00.zip


NI Nick August 5, 2024 06:54 PM UTC

I just upgraded from .NET 7 to 8 and package 26.2.7 from 23.2.6. I got the following error whenever I opened up a page that uses the Scroll.js from your sample.


Error: Microsoft.JSInterop.JSException: Cannot read properties of undefined (reading 'scrollWidth')

TypeError: Cannot read properties of undefined (reading 'scrollWidth')

The HTML does not contain 'e-movable content'.



PS Prathap Senthil Syncfusion Team August 6, 2024 04:46 PM UTC

Hi Nick,

Based on the reported issue, we would like to inform you that we have updated the frozen feature by replacing the previous three-table approach with a single-table approach in version 24.1.41. You can find more details in the release notes: https://blazor.syncfusion.com/documentation/release-notes/24.1.41?type=all#data-grid. Due to these breaking changes, you may have encountered the issue. So, we suggest using the modified code snippet and sample below to achieve your requirements. Thank you for your understanding.


  public async Task RefreshTopScroll()

  {

       

          await JSRuntime.InvokeVoidAsync("Scroll");

       

  }

Scroll.js

function Scroll() {

    var scroll = document.getElementById('wrapper1');

    var grid = document.getElementsByClassName('e-grid')[0].ej2_instances[0];

    var content = document.getElementsByClassName('e-gridcontent')[0]; // Get content    

 

    if (scroll && content) {

        grid.element.insertBefore(scroll, content); // Place the scrollbar between the content and header   

 

        var wrapper1 = document.getElementById("wrapper1");

        wrapper1.style.display = "block";

 

        // Adjust width of the scrollbar wrapper

        document.getElementById("div1").style.width = content.firstElementChild.scrollWidth + "px";

 

        // Bind onscroll event to the wrapper

        wrapper1.onscroll = function () {

            content.firstElementChild.scrollLeft = wrapper1.scrollLeft; // Sync wrapper1 scrollLeft with the Grid scrollLeft

        };

 

        // Bind onscroll event to the content

        content.firstElementChild.onscroll = function () {

            wrapper1.scrollLeft = content.firstElementChild.scrollLeft; // Sync Grid scrollLeft with the wrapper1 scrollLeft

        };

    }

}



Regards,
Prathap Senthil


Attachment: DataGrid_TopScroll_784e4fe5.zip


NI Nick replied to Prathap Senthil December 13, 2024 03:09 AM UTC

Hi, 

The code works but if users switch between pages before the grid data finishes loading the following line in Scroll.js throws an undefined ej2_instances error.


var grid = document.getElementsByClassName('e-grid')[0].ej2_instances[0];


I am calling the script during the grid DataBound event and this method executes even when the user navigates from the page.



PS Prathap Senthil Syncfusion Team December 14, 2024 04:14 AM UTC

We are unable to reproduce the reported issue . For your reference, we have attached a screenshot. To further investigate the issue, we need additional clarification from your side. Please provide the following details to help us proceed:

  • Could you please share the video demonstrations of the issue with replication steps?
  • To help us analyze the issue, could you provide a simple, reproducible sample that demonstrates the problem? This will allow us to identify the issue more effectively and provide a resolution. Alternatively, you could share your attempt to replicate the issue using the previous  attached sample



The information you provide will be very helpful in validating the reported query on our end and in providing a solution as quickly as possible. Thank you for your understanding.




SM Sandip Mane March 18, 2025 01:21 PM UTC

Hi,

I was having a similar requirement to show scrollbar on top and bottom of the grid and I could achieve it by following your code sample from this thread. But, is it possible to make top scrollbar as sticky. Currently my grid column header is made sticky by applying EnableStickyHeader="true" on SfGrid. Scrollbar appears just below grid header which is perect. But, I want both header and scrollbar to be made sticky. Thanks.



SM Sandip Mane March 19, 2025 07:03 AM UTC

Hi,

Also, noticed that top scrollbar does not retain its position when there is any action event in column header such as sorting or filtering. Scrollbar at grid bottom (default grid scrollbar) retains its position, but top scrollbar just goes to the initial leftmost position. Please help.



PS Prathap Senthil Syncfusion Team March 19, 2025 01:40 PM UTC

Based on your requirement, we suggest using the modified code snippet below in the scroll.js file to handle the scrollbar as sticky and achieve your requirement. Kindly refer to the code snippet and sample for your reference

function Scroll() {

    var scroll = document.getElementById('wrapper1');

    var grid = document.getElementsByClassName('e-grid')[0].ej2_instances[0];

    var content = document.getElementsByClassName('e-gridcontent')[0]; // Get content    

    var headerContent = document.getElementsByClassName('e-headercontent')[0]; // Get header content

    if (scroll && content) {

        grid.element.insertBefore(scroll, content); // Place the scrollbar between the content and header   

 

        var wrapper1 = document.getElementById("wrapper1");

        wrapper1.style.display = "block";

        wrapper1.style.position = "sticky";

        wrapper1.style.zIndex = "10";

 

 

        // Function to update the top position

     

        function updateTopPosition() {

            var stickyHeader = document.querySelector('.e-gridheader.e-sticky');

            var topPosition = headerContent.offsetHeight;

 

            if (stickyHeader) {

                topPosition = stickyHeader.getBoundingClientRect().bottom;

            }

 

            wrapper1.style.top = topPosition + "px";

        }

        // Initial call to set the top position

        updateTopPosition();

 

 

        // Adjust width of the scrollbar wrapper

        document.getElementById("div1").style.width = content.firstElementChild.scrollWidth + "px";

 

        // Bind onscroll event to the wrapper

        wrapper1.onscroll = function () {

            content.firstElementChild.scrollLeft = wrapper1.scrollLeft; // Sync wrapper1 scrollLeft with the Grid scrollLeft

        };

 

        // Bind onscroll event to the content

        content.firstElementChild.onscroll = function () {

            wrapper1.scrollLeft = content.firstElementChild.scrollLeft; // Sync Grid scrollLeft with the wrapper1 scrollLeft

        };

 

        // Adjust position on scroll

        window.addEventListener('scroll', updateTopPosition);

    }

}


Attachment: DataGrid_TopScroll_396dd0b.zip


SM Sandip Mane March 20, 2025 01:26 PM UTC

Hi,

Thanks. But, your suggestions did not solve the problems. I tried your code as well and problems seem to be unresolved.

Problem 1 - Grid's top scrollbar does not remain sticky when page is scrolled down.

Problem 2 - Grid's top scrollbar does not retain its scrolled position when user selects any action on grid column header such as sorting or filtering.

Please see attached screenshots explaining the problems.


Attachment: SyncfusionBlazorGridProblems_24e22ceb.zip


PS Prathap Senthil Syncfusion Team March 24, 2025 02:51 AM UTC

Problem 1 - Grid's top scrollbar does not remain sticky when page is scrolled down.

We are unable to reproduce the reported issue. For your reference, we have attached a screen recording. To further investigate the problem, we require additional clarification from your end. Please share the details below so we can proceed accordingly.

  • Could you please share us the video demonstrating of the issue with replication steps ?
  • Are you facing this issue in a specific browser or version? If yes, please share the details.

Above-requested details will be very helpful in validating the reported query at our end and providing a solution as early as possible. Thanks for your understanding.


Problem 2 - Grid's top scrollbar does not retain its scrolled position when user selects any action on grid column header such as sorting or filtering.

Regarding this issue, when performing a data operation, the DataBound event is triggered, causing the JavaScript method to be applied again. To resolve this, you can use a bool property to ensure that the top scrollbar is not rendered again when the DataBound event is triggered. Kindly refer to the code snippet and sample below for your reference.

  public bool Isfirst { get; set; } = true;

 

  public async Task bound()

  {

      if(Isfirst){

          await RefreshTopScroll();

          Isfirst = false;

      }

      


Attachment: BlazorApp1_3edd7695.zip


PS Prathap Senthil Syncfusion Team March 24, 2025 02:54 AM UTC

Please refer to the below attached  screen recording for your reference.


Attachment: TopScrollBarsticky_91c715b2.zip


SM Sandip Mane March 26, 2025 12:20 PM UTC

Hi, Thanks.

First problem was probably some issue at my end, maybe due to caching in browser, but got resolved and is working as expected now.

Second problem got resolved with your suggestion.

I just want to take this opportunity to thank and appreciate you as well as other Syncfusion support team members in this forum who have been patient enough to understand various requirements, problems and answer appropriately with relevant code sample and documentation. This is especially great for people like me who are not very good at UI coding, Javascript, CSS etc. and you guys sometimes going extra length to resolve the problem instead of just providing links to Syncfusion documentation. I hope answers provided to questions in such detail will continue to help other Syncfusion blazor forum members in future.

Thanks again!



NP Naveen Palanivel Syncfusion Team March 27, 2025 11:35 AM UTC


Hi Sandip,


We're glad to hear that your issues have been resolved.  If you have any further questions or need assistance in the future, feel free to reach out. We're always happy to help!


Best regards,
Naveen


Loader.
Up arrow icon